Can an app determine the other apps that are on the phone and what permissions they have?

两盒软妹~` 提交于 2019-12-11 21:06:16

问题


I'm wondering if an app has access to the info that shows the other apps on the phone and what permissions they have (i.e. access to your location, contacts, etc). Could I create an app with a feature that displays other apps and their permissions? I know the user can view this info via settings, but I'm wondering if it can be organized and displayed by an app.


回答1:


Yes. Use the PackageManager. Call GetInstalledPackages to list the installed packages, and then check the requestedPermissions field to see the permissions for each package.

Note: the method below assumes this refers to an Activity.

private void getAppPermissions() {

    List<PackageInfo> apps = this.getPackageManager().getInstalledPackages(PackageManager.GET_PERMISSIONS);

    for (PackageInfo app : apps) {
        String appInfo = app.packageName + ": ";
        String[] permissions = app.requestedPermissions;
        if (null == permissions) {
            appInfo += "no permissions requested\n";
        } else {
            for (String permission : app.requestedPermissions) {
                appInfo += "\n    " + permission;                   
            }
        }
        Log.v("App Permissions", appInfo);
    }
}

You may wish to filter the list of returned packages as per this question.




回答2:


Yes you can. For Android, you just go to Settings > Applications

And you just tap on the application that you want to check, and on the bottom it should say the permissions the app possesses.

For ios, you go to Settings > Privacy

And you tap on the desired type of permission, and you can see the apps that have that permission.



来源:https://stackoverflow.com/questions/24742888/can-an-app-determine-the-other-apps-that-are-on-the-phone-and-what-permissions-t

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