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屋!