navigator.geolocation.getCurrentPosition()当屏幕被锁定 [英] navigator.geolocation.getCurrentPosition() when screen is locked

查看:845
本文介绍了navigator.geolocation.getCurrentPosition()当屏幕被锁定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,它在旅行模式时不断轮询位置。我的问题是,一旦屏幕锁定,应用程序不能再从手机访问地理位置。



我设法找到这个插件,但它需要我购买它的能力,在Android中工作。
http://shop.transistorsoft.com/pages/cordova-background -geolocation-premium



有人知道如果有一个免费选项,我可以用来获得位置成功轮询在Ionic / Cordova应用程序,而

另一个选择是使用部分wakelock ,以便在后台保持您的应用程序活动(屏幕关闭或切换出前台)。您需要通过插件执行此操作,但它会有与后台服务相同的效果,让您的应用程序在后台接收位置更新。



请参阅我的旧答案来查看Cordova 2.0插件的源代码它将需要更新Cordova 3 +)。


I have an App which constantly polls for location when its in travelling mode. My issue is that once the screen is locked, the App can no longer access the geolocation from the phone.

I have managed to find this plugin but it requires I purchase it for the capability to work in Android. http://shop.transistorsoft.com/pages/cordova-background-geolocation-premium

Does anyone know if there is a free option that i can use to get location to successfully poll in an Ionic / Cordova application while the screen is locked?

解决方案

Another option is to use a partial wakelock on Android to keep your app alive while in the background (screen off or switched out of foreground). You'd need to do this via a plugin, but it would have the same effect as a background service, keeping you app alive to receive location updates while in the background.

See my old answer here for the source code for a Cordova 2.0 plugin (it will need updating for Cordova 3+).

这篇关于navigator.geolocation.getCurrentPosition()当屏幕被锁定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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