android - 在 Marshmallow 中授予 ACCESS_FINE_LOCATION 权限时,信标检测停止

标签 android android-6.0-marshmallow altbeacon beacon

我设置了beacon后台扫描using this tutorialBaseApplication 类中,但在 Marshmallow 运行设备中,它显示此日志:

Caught a RuntimeException from the binder stub implementation.
java.lang.SecurityException: Need ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission to get scan results

最后是 thisthis引用我能够为 Marshmallow 运行设备提供位置访问权限以检测信标。

我的问题:

即使我授予位置访问权限,它也不会检测到信标,并且还会停止显示日志上方。是这个问题吗 ISSUE .我的 Nexus 5 内部版本号是 MRA58N

更新:当我手动打开位置时,它现在可以工作了。但这很奇怪。这是检测信标的正确方法吗?

最佳答案

Android Marshmallow 引入了全新的应用程序权限,用户现在可以随时撤销运行时权限。这意味着您不能假设该应用程序有权访问该权限,即使它之前已被授予。可以引用this libthis guide .并且您可以创建一个接口(interface)监听器位置在启用 GPS 后更改,当位置!= 0 时。启用 GPS 后您必须恢复。我希望这会帮助你。

关于android - 在 Marshmallow 中授予 ACCESS_FINE_LOCATION 权限时,信标检测停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33930857/

相关文章:

android-emulator - Android M(预览版)应用程序待机

android - FIleObserver 和 ContentObserver 在 Android Marshmallow 中不起作用

android - 如何以编程方式在 Android 的 API 23 及更高版本中获取位置(lat,lng)?

android - 监控非信标 BLE 设备(Android 信标库)

android - 将 edittext 值定义为字符串

android - SurfaceView 在 PopupWindow 中不工作

android - 识别编辑文本中的当前主题标签或标签

android - Espresso - 如何获取当前 Activity 来测试 Fragments?

android - 大规模崩溃 org.altbeacon.beacon.service.ScanJob -> java.lang.RuntimeException : android. os.DeadSystemException

android - setRangeNotifier(RangeNotifier) 已被弃用?