Xamarin Forms - 每 10 秒获取一次设备位置(当应用程序在前台/后台运行时) [英] Xamarin Forms - Get device location every 10 seconds (when app runs in foreground/background)

查看:25
本文介绍了Xamarin Forms - 每 10 秒获取一次设备位置(当应用程序在前台/后台运行时)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个 Xamarin 表单应用程序.应用程序应定期(每 10 秒)获取设备的位置(iOS 和 Android).我怎样才能做到这一点?我知道有一些库,例如:Xamarin.Essentials,但我无法决定该位置应该被占用多少次.

I have created a Xamarin forms application. The application should periodically (every 10 sec) get the location of the device (iOS and Android). How can I achieve this? I know there are some libraries for example: Xamarin.Essentials, but I can't decide how many times the location should be taken.

当 Xamarin 表单应用程序在后台运行时(在 IOS 和 Android 上),也应该可以获取设备的本地.

It should also be possible to get the local of the device when the Xamarin forms application runs in the background (on IOS and Android).

推荐答案

我过去因为那个头痛而通过了,一个跨平台应用程序,每 x 秒更新一次位置,它应该在后台运行.我在 Xamarin Forms 中开发了一个模板,支持后台位置更新、后台权限,这些功能需要根据操作系统(iOs/Android)进行调整.

I passed for that headache in the past, a cross-platform app that update location every x seconds and it should run in the background. I had developed a template in Xamarin Forms that support Background Location Updates, Background permissions, these capabilities need to be adjusted depending on the OS (iOs/Android).

在此处查看我的 Github 存储库

为此,我使用了 Xamarin Essentials 和消息中心.请让我知道该模板是否适合您的需求.谢谢.

I used Xamarin Essentials and Messaging Center for this purpose. Please let me know if the template works for your needs. Thanks.

这篇关于Xamarin Forms - 每 10 秒获取一次设备位置(当应用程序在前台/后台运行时)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆