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

[Android] Problem with Background Location Refresh #44

Closed
fguarini opened this issue Nov 22, 2016 · 2 comments
Closed

[Android] Problem with Background Location Refresh #44

fguarini opened this issue Nov 22, 2016 · 2 comments

Comments

@fguarini
Copy link

Version Number of Plugin:
-3.0.4
Device Tested On:
-Samsung Galaxy Grand 2 (Android 4.4)
-LG Nexus 4 (Android 5)
-Alcatel Touch Idol (Android 4.1)
Simulator Tested On:
-None

Bug

I am running the following code inside the main thread of the application (inside the PLC) having no issues with iOS as the app continues listening to location updates even when the app is in background or the device is locked. But the position doesn't update on Android once I put it on background. Am I doing something wrong?, should I change the code to run on a new task on Android?. That might be the problem, but it's strange that the code works flawlessly on iOS but just doesn't seem to work on Android.

Code (The relevant parts)

Locator = CrossGeolocator.Current;
Locator.AllowsBackgroundUpdates = true;
Locator.DesiredAccuracy = DESIRED_ACCURACY;
await Locator.StartListeningAsync(MINIMUM_TIME, MINIMUM_DISTANCE, false);
Locator.PositionChanged += OnPositionChangedHandler;

@jamesmontemagno
Copy link
Owner

Only iOS out of the box support background listening such as that.

On Android you must implement your own background service.

Here is a sample: https://github.com/Azure-Samples/MyDriving/tree/master/src/MobileApps/MyDriving/MyDriving.Android/Services

@fguarini
Copy link
Author

fguarini commented Nov 23, 2016

@jamesmontemagno Excellent, thanks a lot for the quick response and reference you gave me! Finally thanks for the Nuget it's awesome 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants