mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Added unregister in onPause
This commit is contained in:
parent
0d188d630c
commit
2742184489
2 changed files with 11 additions and 2 deletions
|
|
@ -39,14 +39,17 @@ public class GPSExtractor {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void registerLocationManager() {
|
protected void registerLocationManager() {
|
||||||
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
|
||||||
criteria = new Criteria();
|
criteria = new Criteria();
|
||||||
provider = locationManager.getBestProvider(criteria, true);
|
provider = locationManager.getBestProvider(criteria, true);
|
||||||
myLocationListener = new MyLocationListener();
|
myLocationListener = new MyLocationListener();
|
||||||
|
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||||
locationManager.requestLocationUpdates(provider, 400, 1, myLocationListener);
|
locationManager.requestLocationUpdates(provider, 400, 1, myLocationListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void unregisterLocationManager() {
|
||||||
|
locationManager.removeUpdates(myLocationListener);
|
||||||
|
}
|
||||||
|
|
||||||
//Extract GPS coords of image
|
//Extract GPS coords of image
|
||||||
public String getCoords() {
|
public String getCoords() {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,12 @@ public class ShareActivity
|
||||||
imageObj.registerLocationManager();
|
imageObj.registerLocationManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
imageObj.unregisterLocationManager();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue