onLocationChanged() never called onLocationChanged() never called android android

onLocationChanged() never called


i run my app on real device .i use network instead of GPS and onLocationChanged is called:

locMan.requestSingleUpdate(LocationManager.NETWORK_PROVIDER, this, null);


Do you never get a location or only as you write in your comment "sometimes it gets location but not at the time of click."?

Might be that your code is faster than LocationManager, which might not yet have called onLocationChanged(). Change your code in order to get the last known location, or wait until your locListener was called:

locManager.requestLocationUpdates(  LocationManager.GPS_PROVIDER, 1000, 1, locListener);mobileLocation = locManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);if (mobileLocation != null) {


LocationManager.NETWORK_PROVIDER need network, but it is real, not precise; if you want to use LocationManager.GPS_PROVIDER, the situation must be outdoor instead of indoor, because GPS location need satellite, if you are in any building, the satellite cannot find you!