Added unregister in onPause

This commit is contained in:
misaochan 2016-02-08 15:58:58 +13:00
parent 0d188d630c
commit 2742184489
2 changed files with 11 additions and 2 deletions

View file

@ -39,14 +39,17 @@ public class GPSExtractor {
}
protected void registerLocationManager() {
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
criteria = new Criteria();
provider = locationManager.getBestProvider(criteria, true);
myLocationListener = new MyLocationListener();
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(provider, 400, 1, myLocationListener);
}
protected void unregisterLocationManager() {
locationManager.removeUpdates(myLocationListener);
}
//Extract GPS coords of image
public String getCoords() {

View file

@ -244,6 +244,12 @@ public class ShareActivity
imageObj.registerLocationManager();
}
@Override
public void onPause() {
super.onPause();
imageObj.unregisterLocationManager();
}
@Override
protected void onDestroy() {
super.onDestroy();