title: How to get just one location with fused location client?
body: <p>What I want is to get just one fresh location and remove location updates after getting first location update and add it to realm but the problem am facing is getting more than 100 locations sometimes in a single update and executing 100 transactions in realm crash app</p>
  
  <pre><code>public void getCurrentLocation(final Context context) {
  
      LocationRequest mLocationRequest;
      final LocationCallback mLocationCallback;
      final FusedLocationProviderClient mFusedLocationClient;
      mFusedLocationClient = LocationServices.getFusedLocationProviderClient(context);
      mLocationRequest = new LocationRequest();
      mLocationRequest.setInterval(60000);
      mLocationRequest.setFastestInterval(60000);
      mLocationRequest.setNumUpdates(1);
      mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
      if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &amp;&amp; ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
          return;
      }
  
  
      mLocationCallback = new LocationCallback() {
          @Override
          public void onLocationResult(LocationResult locationResult)
          {
              if (locationResult == null)
              {
                  return;
              }
              mFusedLocationClient.removeLocationUpdates(this);
  
              Location tempLocation = locationResult.getLastLocation();
              if (locationResult.getLocations().size() &gt; 0)
              {
                  tempLocation = locationResult.getLocations().get(0);
              }
              if(tempLocation != null )
              {
                  RealmManager.writeLocationInRealm(context, tempLocation, true, 0);
              }
          }
      };
  
      mFusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback, null);
  }
  </code></pre>