Skip to content

Commit

Permalink
Merge pull request e-mission#232 from louisg1337/mystery_trip_logs
Browse files Browse the repository at this point in the history
Fixed error in location callback
  • Loading branch information
shankari authored Jul 9, 2024
2 parents 30d6a1c + 5ea160d commit 68d7f83
Showing 1 changed file with 10 additions and 2 deletions.
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

0 comments on commit 68d7f83

Please sign in to comment.