我想检查用户是否已授予我的应用程序使用PACKAGE_USAGE_STATS的权限.我目前正在做的是:
// Control that the required permissions is instantiated!
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ContextCompat.checkSelfPermission(this, Manifest.permission.PACKAGE_USAGE_STATS) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.PACKAGE_USAGE_STATS}, MULTIPLE_PERMISSION_GRANTED);
}
Run Code Online (Sandbox Code Playgroud)
我已经按照Android Developer部分的描述实现了requestPermissions,它对ACCESS_FINE_LOCATION工作正常.
但是,当我的应用程序请求权限时,它只显示ACCESS_FINE_LOCATION权限而不是PACKAGE_USAGE_STATS,任何人都可以解释原因吗?如果是这样,给我一个解决方案,我该怎么做?