title: Get current location with fused Location Provider
body: <p>I have this Activity want to get current location but didn't now how to complete it in right way..also what is REQUEST_CODE_ASK_PERMISSIONS??
  do I have to generate one?</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity implements GoogleApiClient.ConnectionCallbacks,
          GoogleApiClient.OnConnectionFailedListener {
  
  
      private double longitude;
      private double latitude;
      private TextView latitudeText, longitudeText;
      private FusedLocationProviderClient fusedLocationProviderClient;
      private GoogleApiClient googleApiClient;
      private LocationManager locationManager;
      private LocationListener locationListener;
      private LocationRequest locationRequest;
      private LocationCallback locationCallback;
      final private int REQUEST_CODE_ASK_PERMISSIONS = 123;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          latitudeText = findViewById(R.id.latitudeText);
          longitudeText = findViewById(R.id.longitudeText);
  
  
  
          getLocation();
  
      }
  
      private void getLocation() {
  
          locationRequest = new LocationRequest()
                  .setInterval(2000).setFastestInterval(2000).setPriority(1000);
  
  
          LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder()
                  .addLocationRequest(locationRequest);
  
          SettingsClient client = LocationServices.getSettingsClient(this);
          Task&lt;LocationSettingsResponse&gt; task = client.checkLocationSettings(builder.build());
  
          locationCallback = new LocationCallback() {
  
              @Override
              public void onLocationResult(LocationResult locationResult) {
  
                  for (Location location : locationResult.getLocations()) {
  
                      latitude = location.getLatitude();
                      longitude = location.getLongitude();
  
                      latitudeText.setText(String.valueOf(latitude));
                      longitudeText.setText(String.valueOf(longitude));
  
  
  
                  }
              }
          };
  
  
          task.addOnSuccessListener(this, new OnSuccessListener&lt;LocationSettingsResponse&gt;() {
              @Override
              public void onSuccess(LocationSettingsResponse locationSettingsResponse) {
  
  
              }
          });
  
      }
  
  
  
      @Override
      protected void onResume() {
          super.onResume();
  
          if (ContextCompat.checkSelfPermission(this,Manifest.permission.ACCESS_FINE_LOCATION)
                  != PackageManager.PERMISSION_GRANTED){
  
              ActivityCompat.requestPermissions(MainActivity.this,new String[]{Manifest
                      .permission.ACCESS_FINE_LOCATION},REQUEST_CODE_ASK_PERMISSIONS);
  
          } else if(){
  
          }
  
  
  
  
  
  
          }
  
  
      @Override
      public void onConnected(@Nullable Bundle bundle) {
  
      }
  
      @Override
      public void onConnectionSuspended(int i) {
  
      }
  
      @Override
      public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
  
      }
  
  }
  </code></pre>
  
  <p>.....................................................................................................................................................</p>