public void stopUpdates() {
   // revert previous location settings
   final ContentResolver contentResolver = getContentResolver();
   Settings.Secure.putInt(contentResolver, Settings.Secure.LOCATION_MODE, mCurrentLocationmode);
   LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
   stopSelf();
 }
 /**
  * Called each time we receive a new location notification. - sends the location back to the
  * LocationReceiver that requested the location.
  */
 public void onLocationChanged(Location loc) {
   Log.i(TAG, "onLocationChanged() - location found.");
   if (loc != null) {
     Log.i(TAG, "OnLocationChanged() - returning Location (" + loc.toString() + ")");
     Toast.makeText(
         mContext,
         "Location is (" + loc.getLatitude() + "," + loc.getLongitude() + ")",
         Toast.LENGTH_LONG);
     LonLat ll;
     ll =
         new LonLat(
             loc.getLongitude(),
             loc.getLatitude(),
             loc.getAccuracy(),
             loc.getProvider(),
             new Date(loc.getTime()));
     // Now we have a location, unsubscribe from location updates.
     LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
     // And retrn the location to the requesting process.
     lr.onLocationFound(ll);
   } else {
     Log.i(TAG, "onLocationChanged() - Location is null????");
     Toast.makeText(mContext, "No Location Detected", Toast.LENGTH_LONG).show();
     lr.onLocationFound(null);
   }
 }
Example #3
0
 @Override
 public void onLocationChanged(Location location) {
   // Once location update is received remove listener and retrieve posts
   lastLocation = location;
   LocationServices.FusedLocationApi.removeLocationUpdates(client, this);
   getPosts();
 }
  /** @brief This function starts the GPS */
  private void stopLocation() {
    // Check if we need to set up Google API
    if (sGPSIsOn) {
      if (sGoogleApi == null) {
        // Build API
        sGoogleApi =
            new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(LocationServices.API)
                .build();

        // Thank the 6 God for blockingConnect
        ConnectionResult what = sGoogleApi.blockingConnect();
      }

      if (sLocationIntent == null) {
        Intent intent = new Intent(this, InnerLocationService.class);
        sLocationIntent =
            PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
      }
      if (!sQuickGPSIsOn) {
        InnerLocationService.sPreviousLocation = null;
        InnerLocationService.sCurrentLocation = null;
      }

      LocationServices.FusedLocationApi.removeLocationUpdates(sGoogleApi, sLocationIntent);
      sGPSIsOn = false;
      sQuickGPSIsOn = false;
    }
  }
 @Override
 protected void onPause() {
   super.onPause();
   if (mGoogleApiClient.isConnected()) {
     LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
     mGoogleApiClient.disconnect();
   }
 }
 private void detachRecorder() {
   if (locationClientAPI == null) {
     connectToPlayAPI();
   } else if (locationClientAPI.isConnected()) {
     LocationServices.FusedLocationApi.removeLocationUpdates(locationClientAPI, this);
     Log.d(TAG, "- locationUpdateReceiver NO LONGER RECORDING!!!!!!!!!!");
   } else {
     locationClientAPI.connect();
   }
 }
  public void removeUpdates() {
    if (mGoogleApiClient == null) {
      return;
    }

    mLocationRequestTimeOut.cancel();
    if (mGoogleApiClient.isConnected()) {
      LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
    }
  }
 /*
     @Override
     public void onDisconnected() {
         // nop
     }
 */
 @Override
 public void onLocationChanged(Location location) {
   // 現在地に移動
   CameraPosition cameraPos =
       new CameraPosition.Builder()
           .target(new LatLng(location.getLatitude(), location.getLongitude()))
           .zoom(16.0f)
           .bearing(0)
           .build();
   mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPos));
   LocationServices.FusedLocationApi.removeLocationUpdates(mLocationClient, this);
 }
 @Override
 public void onMainFragmentInteraction(int task) {
   switch (task) {
     case FragmentActivityInterfaceConstants.START_LOCATION_UPDATES:
       startLocationUpdates();
       break;
     case FragmentActivityInterfaceConstants.STOP_LOCATION_UPDATES_AND_DISCONNECT_GOOGLE_API:
       if (mGoogleApiClient.isConnected()) {
         // Just like we have to disconnect our client, we also need to explicitly
         // remove location updates after requesting them. We do this with the opposite method,
         // which we can call in onPause() when we disconnect our Google API client:
         LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
         mGoogleApiClient.disconnect();
       }
       break;
     case FragmentActivityInterfaceConstants.DISABLE_PAGER_TITLESTRIP:
       mPagerTitleStrip.setBackgroundColor(Color.parseColor("#039BE5"));
       break;
     case FragmentActivityInterfaceConstants.ENABLE_PAGER_TITLESTRIP:
       mPagerTitleStrip.setBackgroundColor(Color.parseColor("#01579B"));
       break;
   }
 }
Example #10
0
 public void disconnect() {
   if (mGoogleApiClient.isConnected()) {
     LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
     mGoogleApiClient.disconnect();
   }
 }
 private void finishTracking() {
   if (googleApiClient.isConnected()) {
     LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, this);
     googleApiClient.disconnect();
   }
 }
 protected void stopLocationUpdates() {
   LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
   mRequestingLocationUpdates = false;
 }
Example #13
0
 protected void stopLocationUpdates() {
   LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
   Log.d("TAG", "Location update stopped .......................");
 }
 /** Stopping location updates */
 protected void stopLocationUpdates() {
   LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
 }
 public void changePriority(GoogleApiClient mGoogleApiClient, int newPriority) {
   locationRequest.setPriority(newPriority);
   LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
   LocationServices.FusedLocationApi.requestLocationUpdates(
       mGoogleApiClient, locationRequest, this);
 }
 public void changeInterval(GoogleApiClient mGoogleApiClient, int newInterval) {
   locationRequest.setInterval(newInterval);
   LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
   LocationServices.FusedLocationApi.requestLocationUpdates(
       mGoogleApiClient, locationRequest, this);
 }
 public void stopLocationUpdates(GoogleApiClient mGoogleApiClient) {
   LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
 }
Example #18
0
 @Override
 public void onLocationChanged(Location location) {
   mLocation = location;
   updateLocation(mLocation);
   LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
 }
 protected void stopLocationUpdates() {
   if (googleApiClient.isConnected()) {
     LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, this);
     googleApiClient.disconnect();
   }
 }