简体   繁体   English

如何在Android应用程序中获取所有具有互联网许可的应用程序?

[英]How can I get all applications that have the internet permission in Android Applications?

How can I get all applications that have the internet permission in Android? 如何获得Android中所有具有互联网许可的应用程序? How can I do that? 我怎样才能做到这一点? any idea? 任何想法?

You need to iterate over all installed apps, using the PackageManager.GET_PERMISSIONS flag. 您需要使用PackageManager.GET_PERMISSIONS标志迭代所有已安装的应用程序。 You can then check if the internet permission is in the returned value. 然后,您可以检查互联网权限是否在返回值中。

Sample code (based on this answer ): 示例代码(基于此答案 ):

PackageManager p = context.getPackageManager(); 
final List<PackageInfo> apps = p.getInstalledPackages(PackageManager.GET_PERMISSIONS);
for (PackageInfo pkg : apps) {
    for (String permission : pkg.requestedPermissions) {
        // Check if permission is the internet permission
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM