Android M 权限对话框未显示 [英] Android M permission dialog not showing
问题描述
我目前正在尝试使我的应用程序适应 Android M 的新权限模型.
I'm currently trying to adapt my application to the new permissions model of Android M.
我正在收集我需要的所有权限,然后运行
I'm collecting all the permissions I require, then run
Log.i("Permissions", "Requesting permissions: " + permissions);
requestPermissions(requiredPermissions.toArray(new String[requiredPermissions.size()]), requestCodeForPermissions);
requiredPermissions 持有我需要的权限,例如 android.permission.WRITE_EXTERNAL_STORAGE
.
requiredPermissions holds the permissions I need like android.permission.WRITE_EXTERNAL_STORAGE
.
该例程肯定会执行,因为我在 logcat 中有 Log 行:
That routine is definitely executed as I have the Log line in the logcat:
08-07 12:52:46.469: I/Permissions(1674): Requesting permissions: android.permission.RECEIVE_BOOT_COMPLETED; android.permission.WRITE_EXTERNAL_STORAGE
但权限对话框从未显示,更不用说调用了 onRequestPermissionsResult().
But the permissions dialog never shows, let alone is onRequestPermissionsResult() called.
我做错了什么?根据一些教程,我发现我没有遗漏任何东西.我只有模拟器用于测试,没有物理设备.这是设置中的关于屏幕:图片
What am I doing wrong? Based on some tutorials I found I'm not missing anything. I only have the emulator for testing, no physical device. This is the about screen from settings: Image
可能值得一提的是:如果我尝试从主屏幕打开已安装应用的概览,我只会看到 launcher3 has exited
.我不确定这是否相关.
It might be worth mentioning something else: If I try to open the overview of installed apps from the home screen I only get launcher3 has exited
. I'm not sure if that might be related.
有人知道为什么它不显示吗?
Does anybody have an idea why it's not showing?
推荐答案
基于 Hilal 的评论(非常感谢!):在我的情况下,我的应用程序确实使用了 tabhost,并且权限是从 tabhost 内的 Activity 请求的.启动请求权限的单独活动后,它正在工作.
Based on the comment from Hilal (thanks a lot!): In my case my app is indeed using tabhost and the permissions were requested from an Activity inside the tabhost. After starting a separate activity that requests the permissions it is working.
这篇关于Android M 权限对话框未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!