我有这段代码来获取所有使用 Internet 权限的应用程序,但是出了点问题,请帮助我 :)
public String[] getAppsWithNet() {
int flag = 0;
String[] appsNet = new String[50];
PackageManager p = c.getPackageManager();
final List<PackageInfo> apps = p.getInstalledPackages(PackageManager.GET_PERMISSIONS);
for (PackageInfo pkg : apps) {
for (String permission : pkg.requestedPermissions) {
if (p.PERMISSION_GRANTED == p.checkPermission(Manifest.permission.INTERNET, pkg.packageName)) {
appsNet[flag] = pkg.packageName;
flag++;
}
}
}
return appsNet;
}
预先感谢...