Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug #457 - Use of GnssStatus #458

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class GpsConnection {
private final MyLocationListener llGPS;
private final MyLocationListener llNetwork;
private final MyGpsListener gpsListener;
private final MyGnssListener gnssListener;
private boolean isFixed;
private Timer mGpsTimer;
// temp variable for indicating whether network provider is enabled
Expand All @@ -58,6 +59,7 @@ public GpsConnection(Context context) {
llGPS = new MyLocationListener();
llNetwork = new MyLocationListener();
gpsListener = new MyGpsListener();
gnssListener = new MyGnssListener();

// init basic fixing values
isFixed = false;
Expand Down Expand Up @@ -105,7 +107,6 @@ public GpsConnection(Context context) {
// add new listener GPS
try {
if (Build.VERSION.SDK_INT >= 24) {
MyGnssListener gnssListener = new MyGnssListener();
locationManager.registerGnssStatusCallback(gnssListener);
} else {
locationManager.addGpsStatusListener(gpsListener);
Expand All @@ -131,7 +132,11 @@ public void destroy() {
if (locationManager != null) {
disableNetwork();
locationManager.removeUpdates(llGPS);
locationManager.removeGpsStatusListener(gpsListener);
if (Build.VERSION.SDK_INT >= 24) {
locationManager.unregisterGnssStatusCallback(gnssListener);
} else {
locationManager.removeGpsStatusListener(gpsListener);
}
locationManager = null;
// XXX missing context to notify by widget
ManagerNotify.toastShortMessage(R.string.gps_disabled);
Expand Down