mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +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;
|
private Context context;
|
||||||
public boolean imageCoordsExists;
|
public boolean imageCoordsExists;
|
||||||
private MyLocationListener myLocationListener;
|
private MyLocationListener myLocationListener;
|
||||||
|
private LocationManager locationManager;
|
||||||
|
private String provider;
|
||||||
|
private Criteria criteria;
|
||||||
|
|
||||||
public GPSExtractor(String filePath, Context context){
|
public GPSExtractor(String filePath, Context context){
|
||||||
this.filePath = filePath;
|
this.filePath = filePath;
|
||||||
|
|
@ -35,6 +38,15 @@ public class GPSExtractor {
|
||||||
return gpsPref;
|
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
|
//Extract GPS coords of image
|
||||||
public String getCoords() {
|
public String getCoords() {
|
||||||
|
|
||||||
|
|
@ -60,13 +72,7 @@ public class GPSExtractor {
|
||||||
boolean gpsPrefEnabled = gpsPreferenceEnabled();
|
boolean gpsPrefEnabled = gpsPreferenceEnabled();
|
||||||
|
|
||||||
if (gpsPrefEnabled) {
|
if (gpsPrefEnabled) {
|
||||||
//If pref enabled, set up LocationListener to get current location
|
//If pref enabled, 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);
|
|
||||||
Location location = locationManager.getLastKnownLocation(provider);
|
Location location = locationManager.getLastKnownLocation(provider);
|
||||||
|
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue