Can an app determine the other apps that are on th

2019-09-09 19:39发布

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.

2条回答
forever°为你锁心
2楼-- · 2019-09-09 19:55

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.

查看更多
我想做一个坏孩纸
3楼-- · 2019-09-09 20:08

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.

查看更多
登录 后发表回答