I am trying to fetch the logged in user's lat and long using LocationManager. I am able to get the Permissions Screen and after allowing i want to see the Lat and Long on the Text View. But, i am not able to see anything in the text view.
protected void getLocation() {
Log.v(TAG, "GetLocation");
int LOCATION_REFRESH_TIME = 1000;
int LOCATION_REFRESH_DISTANCE = 5;
if (!(checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)) {
Log.v("WEAVER_", "Has permission");
mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, LOCATION_REFRESH_TIME,
LOCATION_REFRESH_DISTANCE, mLocationListener);
} else {
Log.v("WEAVER_", "Does not have permission");
}
}
Now, i am calling mLocationListener, but not getting any results neither any error. OnLocationChanged() method is not getting called.
private final LocationListener mLocationListener = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
Log.v("WEAVER_", "Location Change");
double latitude = location.getLatitude();
textView.setText(String.valueOf(latitude) + "latitude");
textView.setText(String.valueOf(updates) + " updates");
}
Here, the textView does not show anything, neither the log is updated with Location Changed Event.
The Log results are:
08-21 14:35:29.336 3390-3390/daveytree.geo2 V/WEAVER_: GetLocation
08-21 14:35:29.337 3390-3390/daveytree.geo2 V/WEAVER_: Has permission
08-21 14:35:29.362 3390-3526/daveytree.geo2 D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
Is there any other event to capture this. Please help