@Test public void shouldNotHaveListenerOnceRemoved() { Listener listener = addGpsListenerToLocationManager(); locationManager.removeGpsStatusListener(listener); assertFalse(shadowLocationManager.hasGpsStatusListener(listener)); }
private void unregisterGPSListener() { if (locationManager != null) { locationManager.removeGpsStatusListener(gpsStatusListener); } }
/** * Release GPS Status Listener */ public synchronized void unRegister() { if (locationManager == null) return; locationManager.removeGpsStatusListener(listener); locationManager = null; }
/** * Cancels GPS update notification */ private void disableUpdates() { if (lmgr != null) { try { lmgr.removeGpsStatusListener(this); lmgr.removeUpdates(this); } catch (SecurityException e) { Log.i(TAG, "You denied GPS permission, so we don't need a perform a proper cleanup here"); } } }
@Override protected void onPause() { super.onPause(); mLocationManager.removeUpdates(this); mLocationManager.removeGpsStatusListener(this); SharedPreferences.Editor prefsEditor = sharedPreferences.edit(); Gson gson = new Gson(); String json = gson.toJson(data); prefsEditor.putString("data", json); prefsEditor.commit(); }
public void stopAutocorrect() { try { mLocationManager.removeGpsStatusListener(mGpsStatusListener); mLocationManager.removeUpdates(gpsAutocorrectLocationListener); mHandler.removeCallbacks(autoStopTask); mHandler.removeCallbacks(satelitesInRangeTest); if (BuildConfig.debug) Log.i("Location-Status", "shutdown Autocorrect"); if (GoogleMap.backgroundServiceShallBeOnAgain == true) { Config.backgroundServiceActive = true; BackgroundService.reactivateFakeProvider(); } } catch (SecurityException e) { e.printStackTrace(); } }
@Override protected void onDestroy() { super.onDestroy(); mLocationManager.removeGpsStatusListener(mGpsStatusListener); unregisterReceiver(mReceiver); }
public void updateGPSLocationFrequency () { if (isGPSLocationUpdatesActive && (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED)) { mlocManager.removeGpsStatusListener(this); mlocManager.removeUpdates(this); StabilizingSamples = (int) Math.ceil(STABILIZERVALUE / prefGPSupdatefrequency); mlocManager.addGpsStatusListener(this); mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, prefGPSupdatefrequency, 0, this); } }
@Override public void onDestroy() { mLocationManager.removeUpdates(this); mLocationManager.removeGpsStatusListener(this); stopForeground(true); }
@Override protected void onDestroy() { super.onDestroy(); mLocationManager.removeGpsStatusListener(mGpsStatusListener); unregisterReceiver(mReceiver); }
@Override protected void onDestroy() { super.onDestroy(); mLocationManager.removeGpsStatusListener(mGpsStatusListener); unregisterReceiver(mReceiver); }
public void requestLocationUpdates(boolean request) { if (request) { if (ContextCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { lmgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this); lmgr.addGpsStatusListener(this); } else { ActivityCompat.requestPermissions((Activity) activity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_CODE_GPS_PERMISSIONS); } } else { lmgr.removeUpdates(this); lmgr.removeGpsStatusListener(this); } }
/** * */ public synchronized void stop() { /* * Stop but dont stop if already stopped */ if(null != mLocationManager) { mLocationManager.removeUpdates(this); mLocationManager.removeGpsStatusListener(this); mLocationManager.removeNmeaListener(this); mLocationManager = null; return; } if(null != mTimer) { mTimer.cancel(); mTimer = null; } }
public void setGPSLocationUpdates (boolean state) { // Request permissions = https://developer.android.com/training/permissions/requesting.html if (!state && !getRecording() && isGPSLocationUpdatesActive && (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED)) { GPSStatus = GPS_SEARCHING; mlocManager.removeGpsStatusListener(this); mlocManager.removeUpdates(this); isGPSLocationUpdatesActive = false; } if (state && !isGPSLocationUpdatesActive && (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED)) { mlocManager.addGpsStatusListener(this); mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, prefGPSupdatefrequency, 0, this); // Requires Location update isGPSLocationUpdatesActive = true; StabilizingSamples = (int) Math.ceil(STABILIZERVALUE / prefGPSupdatefrequency); } }
super.onPause(); mLocationManager.removeUpdates(mLocationListener); mLocationManager.removeGpsStatusListener(mGpsListener);
@Override public void onDestroy() { super.onDestroy(); if (PERMISSIONS_OK) locationManager.removeUpdates(this); locationManager.removeGpsStatusListener(gps_status_listener); ContentResolver.setSyncAutomatically(Aware.getAWAREAccount(this), Locations_Provider.getAuthority(this), false); ContentResolver.removePeriodicSync( Aware.getAWAREAccount(this), Locations_Provider.getAuthority(this), Bundle.EMPTY ); if (Aware.DEBUG) Log.d(TAG, "Locations service terminated..."); }
@Override protected void onDestroy() { super.onDestroy(); if (mLocService != null) { mLocService.removeGpsStatusListener(this); mLocService.removeUpdates(this); } releaseWakeLockIfHeld(); if (isServiceBound) { doUnbindService(); } endTrip(); final BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter(); if (btAdapter != null && btAdapter.isEnabled() && !bluetoothDefaultIsEnable) btAdapter.disable(); }
Integer.parseInt(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LOCATION_GPS)) * 1000, Integer.parseInt(Aware.getSetting(getApplicationContext(), Aware_Preferences.MIN_LOCATION_GPS_ACCURACY)), this); locationManager.removeGpsStatusListener(gps_status_listener); locationManager.addGpsStatusListener(gps_status_listener);
locationManager.removeGpsStatusListener(state.gpsListener);
locationManager.removeGpsStatusListener(state.gpsListener); try { locationManager.removeUpdates(state.gpsListener);