一个应用程序可以判断是手机和权限它们对其他应用程序? [英] Can an app determine the other apps that are on the phone and what permissions they have?

查看:127
本文介绍了一个应用程序可以判断是手机和权限它们对其他应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如果一个应用程序可以访问,显示的电话,他们有(即存取您的位置,联系方式等),哪些权限的其他应用程序的信息。我可以创建与显示其他应用程序和权限的功能的应用程序?我知道,用户可以查看通过设置这个信息,但我想知道,如果它可以通过一个应用程序来组织和显示。

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.

推荐答案

是的。使用 软件包管理系统 。呼叫<一个href=\"http://developer.android.com/reference/android/content/pm/PackageManager.html#getInstalledPackages(int)\"相对=nofollow> GetInstalledPackages 列出已安装的软件包,然后检查<一个href=\"http://developer.android.com/reference/android/content/pm/PackageInfo.html#requestedPermissions\"相对=nofollow> requestedPermissions 现场看到每个包的权限。

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.

这篇关于一个应用程序可以判断是手机和权限它们对其他应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆