Does anybody is able to find a working solution for guraneteed call to onLocationChanged(...) method of LocationListener? Looks like many peoples are facing this issue. https://code.google.com/p/android/issues/detail?id=57707 my implentation is not at all getting called even after trying and trying many ways...
public class MyLocationListener implements LocationListener{
final String _logTag = "Location listener";
public void onLocationChanged(Location location) {
String provider = location.getProvider();
double lat = location.getLatitude();
double lng = location.getLongitude();
float accuracy = location.getAccuracy();
long time = location.getTime();
Log.d("long"," "+lng);
String logMessage = LogHelper.formatLocationInfo(provider, lat, lng, accuracy, time);
Log.d(_logTag, "Monitor Location:" + logMessage);
}
public void onStatusChanged(String s, int i, Bundle bundle) {
String statusMessage = LogHelper.translateStatus(i);
// Log.d(_logTag, "Monitor Location - Status:" + statusMessage);
Set<String> keys = bundle.keySet();
for(String key:keys){
Log.d(_logTag, "Monitor Location - Bundle Key:" + key);
}
}
public void onProviderEnabled(String s) {
Log.d(_logTag, "Monitor Location - Provider ENABLED by USER: " + s);
}
public void onProviderDisabled(String s) {
Log.d(_logTag, "Monitor Location - Provider DISABLED by USER: " + s);
}
}
This is what I've used in the past, it works pretty well for me: