Android 11中的位置更新 [英] Location Updates in Android 11

查看:85
本文介绍了Android 11中的位置更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用跟踪从前台定期启动的前台服务中的位置更新,并在添加android:foregroundServiceType ="location"后在Android Q中正常工作,但是在Android 11 beta中,它不再接收位置.

My app traces location updates in foreground services periodically started from background and is working properly in Android Q after adding android:foregroundServiceType="location" but in Android 11 beta it does not receive locations anymore.

这种方式是11中的新功能还是错误?我没有在文档中看到任何东西.

Is this manner new in 11 or just a bug? I did not see anything in the documents.

推荐答案

从Android 11开始,前台的位置"服务已不足以获取后台位置更新.如果前台服务是在后台启动的(例如广播接收器),我们现在需要请求ACCESS_BACKGROUND_LOCATION:

Starting with Android 11, a foreground "location" service is no longer enough to get background location updates. We now need to request ACCESS_BACKGROUND_LOCATION, if the foreground service is started in the background (such as a broadcast receiver):

https://developer.android.com/about/versions/oreo/background-location-limits

更糟糕的是,您必须与其他位置权限分开请求ACCESS_BACKGROUND_LOCATION,否则它将不起作用:

Even worse, you have to request ACCESS_BACKGROUND_LOCATION separately from the other location permissions, or it won't work:

https://developer.android.com/about/versions/11/privacy/location

这篇关于Android 11中的位置更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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