Skip to content
Closed
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 @@ -34,6 +34,9 @@

class FusedLocationClient implements LocationClient {
private static final String TAG = "FlutterGeolocator";
private static final long DIALOG_SHOW_INTERVAL_MS = 30 * 60 * 1000; // 30 minutes
private static boolean isDialogShowing = false;
private static long lastDialogShowTime = 0;

private final Context context;
private final LocationCallback locationCallback;
Expand Down Expand Up @@ -200,6 +203,8 @@ public void getLastKnownPosition(
}

public boolean onActivityResult(int requestCode, int resultCode) {
isDialogShowing = false;

if (requestCode == activityRequestCode) {
if (resultCode == Activity.RESULT_OK) {
if (this.locationOptions == null
Expand Down Expand Up @@ -252,10 +257,19 @@ public void startPositionUpdates(
int statusCode = rae.getStatusCode();
if (statusCode == LocationSettingsStatusCodes.RESOLUTION_REQUIRED) {
try {
long currentTime = System.currentTimeMillis();
if (isDialogShowing || (lastDialogShowTime != 0 && (currentTime - lastDialogShowTime) < DIALOG_SHOW_INTERVAL_MS)) {
return;
}

// Show the dialog by calling startResolutionForResult(), and check the
// result in onActivityResult().
rae.startResolutionForResult(activity, activityRequestCode);

isDialogShowing = true;
lastDialogShowTime = currentTime;
} catch (IntentSender.SendIntentException sie) {
isDialogShowing = false;
errorCallback.onError(ErrorCodes.locationServicesDisabled);
}
} else {
Expand Down