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

Fixed error in location callback #232

Merged
merged 2 commits into from
Jul 9, 2024
Merged
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
12 changes: 10 additions & 2 deletions src/android/location/ActivityRecognitionChangeIntentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.android.gms.location.LocationAvailability;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.location.LocationSettingsResponse;
import com.google.android.gms.location.LocationSettingsStates;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import android.content.Context;
Expand Down Expand Up @@ -66,14 +67,21 @@ protected void onHandleIntent(Intent intent) {
Log.d(this, TAG, "Beginning checks for trip disappearance...");

// Check to see if the foreground service is still alive
Context ctxt = getApplicationContext();
final Context ctxt = getApplicationContext();
TripDiaryStateMachineForegroundService.checkForegroundNotification(ctxt);

// Check if can retrieve current location
OnCompleteListener<LocationSettingsResponse> callback = new OnCompleteListener<LocationSettingsResponse>() {
@Override // no-op
public void onComplete(Task<LocationSettingsResponse> task) {
Log.d(this, TAG, "While checking location status in activity response, received callback with : " + task);
if (task.isSuccessful()) {
LocationSettingsStates result = task.getResult().getLocationSettingsStates();
// Docs for what we can check using LocationSettingsStates https://developers.google.com/android/reference/com/google/android/gms/location/LocationSettingsStates
Log.d(ctxt, TAG, "While checking location status in activity response, got responses... isGpsUsable(): " + result.isGpsUsable() + " isLocationUsable(): " + result.isLocationUsable() + " isNetworkLocationUsable(): " + result.isNetworkLocationUsable());
} else {
Exception error = task.getException();
Log.d(ctxt, TAG, "While checking location status in activity response, got exception... " + error.getMessage());
}
}
};
SensorControlChecks.checkLocationSettings(this, callback);
Expand Down