I am working in app where user location tracking all time and updated into server in background service, i update location to the server from onLocationChanged(Location location) @Override method. I want hit server when location is not changed also. is there any @Override method who is call when Gps is off?Mean,i want to notify the server that user's gps is off.
Asked
Active
Viewed 181 times
0
-
if your app close than FusedLocationProviderApi running in background ?? – Muhammad Younas May 21 '16 at 05:50
-
1yes,in all 10 secend interval – Suman May 21 '16 at 05:53
-
Hi Younas Bangash,any override method or anything when user off the location? – Suman May 21 '16 at 06:26
-
Ok can you share the code please – Muhammad Younas May 21 '16 at 06:50
1 Answers
0
You can detect GPS on/off event/status with GpsStatus.Listener and register it with the LocationManager.
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
lm.addGpsStatusListener(new android.location.GpsStatus.Listener()
{
public void onGpsStatusChanged(int event)
{
switch(event)
{
case GPS_EVENT_STARTED:
// do your tasks
break;
case GPS_EVENT_STOPPED:
// do your tasks
break;
}
}
});

USKMobility
- 5,721
- 2
- 27
- 34
-
thanks,for you contribution.but i want when gps off then fuesed location notify and then notify the server. – Suman May 21 '16 at 06:37
-
no override method available to detect the GPS is off. You try trick, onConnectionSuspended and onConnectionfailed and check your GPS is off then notify to the server. I think better to add GPS listener – USKMobility May 21 '16 at 06:51
-
thank you,but when called onConnectionSuspended and onConnectionfailed ?because when i off the Gps then it is not called.. – Suman May 21 '16 at 12:41