Reputation: 571
I used location manager for change status of GPS in navigation app. But it not working in android 10 (samsung a10). Unfortunately broadcast receiver is limited in android 10.
My code is:
locationManager.addGpsStatusListener(new GpsStatus.Listener() {
@Override
public void onGpsStatusChanged(int event) {
switch (event) {
case GpsStatus.GPS_EVENT_STARTED:
Log.i(TAG, "GpsStatusChanged started");
break;
case GpsStatus.GPS_EVENT_STOPPED:
Log.i(TAG, "GpsStatusChanged stopped");
break;
case GpsStatus.GPS_EVENT_FIRST_FIX:
break;
case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
break;
}
}
});
How to resolve it?
Thanks for your help...
Upvotes: 3
Views: 4154
Reputation: 189
Yes when I updated the target to API 33 , it fails and says its deprecated. But this will work till API 31 see this link
We need to use the GnssStatus as given in the code example
Upvotes: 0
Reputation: 4039
addGpsStatusListener
is deprecated in API level 24
.
Please use LocationManager.registerGnssStatusCallback(GnssStatus.Callback)
instead.
More info, go to the documentation
Upvotes: 3