Retrieve Permissions list

我与影子孤独终老i 提交于 2019-12-21 05:09:35

问题


I'm trying to retrieve the permissions of the apps in my device.

The weird thing is, for some apps I do get results, and in some of them I can't retrieve any permissions.

Maybe in order to get the permissions list of an app, the app has to set some specific flag? Because if I try to get the permission list of my app in this way:

PackageManager p = context.getPackageManager();
PermissionInfo[] z=p.getPackageInfo("com.test.myapp",PackageManager.GET_PERMISSIONS).permissions);

z is null, but for some apps (system apps, etc..) I do get some list.

Any idea?

Thanks, moshik.


回答1:


As far as i discovered it, the PermissionInfo contains only non-default permissions ( other than android.Manifest.permission.* ).

The only way ( i found ) is to manually check the android.Manifest.permission.* via

PackageManager.checkPermission(String permName, String pkgName); 


来源:https://stackoverflow.com/questions/3353773/retrieve-permissions-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!