Skip to content
This repository was archived by the owner on Mar 15, 2025. It is now read-only.
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