mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
New registerLocationUpdates() function
This commit is contained in:
parent
565e60f666
commit
e5b746e411
1 changed files with 13 additions and 7 deletions
|
|
@ -22,6 +22,9 @@ public class GPSExtractor {
|
|||
private Context context;
|
||||
public boolean imageCoordsExists;
|
||||
private MyLocationListener myLocationListener;
|
||||
private LocationManager locationManager;
|
||||
private String provider;
|
||||
private Criteria criteria;
|
||||
|
||||
public GPSExtractor(String filePath, Context context){
|
||||
this.filePath = filePath;
|
||||
|
|
@ -35,6 +38,15 @@ public class GPSExtractor {
|
|||
return gpsPref;
|
||||
}
|
||||
|
||||
private void registerLocationManager() {
|
||||
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||
criteria = new Criteria();
|
||||
provider = locationManager.getBestProvider(criteria, true);
|
||||
myLocationListener = new MyLocationListener();
|
||||
|
||||
locationManager.requestLocationUpdates(provider, 400, 1, myLocationListener);
|
||||
}
|
||||
|
||||
//Extract GPS coords of image
|
||||
public String getCoords() {
|
||||
|
||||
|
|
@ -60,13 +72,7 @@ public class GPSExtractor {
|
|||
boolean gpsPrefEnabled = gpsPreferenceEnabled();
|
||||
|
||||
if (gpsPrefEnabled) {
|
||||
//If pref enabled, set up LocationListener to get current location
|
||||
LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||
Criteria criteria = new Criteria();
|
||||
String provider = locationManager.getBestProvider(criteria, true);
|
||||
|
||||
myLocationListener = new MyLocationListener();
|
||||
locationManager.requestLocationUpdates(provider, 400, 1, myLocationListener);
|
||||
//If pref enabled, get current location
|
||||
Location location = locationManager.getLastKnownLocation(provider);
|
||||
|
||||
if (location != null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue