Home > Mobile >  Background Location Tracking for Android with Xamarin.Forms
Background Location Tracking for Android with Xamarin.Forms

Time:09-27

I am creating a xamarin form app which require user location after every 10 meter. I am able to get location when app is running in foreground but unable to get location when app get into background. Any advice will be great.

CodePudding user response:

You need to create a background service in Xamarin.Android and then call that using dependency services. You could also look at Shiny. It is a good plugin built for this purpose.

https://github.com/shinyorg/shiny

CodePudding user response:

Background updates are handled a bit different on each platform. For Android, you will want to integrate a foreground service that subscribes to location changes and the user interface binds to.

You could use the Xamarin.Essentials and MessagingCenter for this.

For more details, please check the code sample in the link below. https://stackoverflow.com/a/63665571/11850033

  • Related