获取 android 中具有互联网权限的应用程序列表
get list of application which have internet permission in android
我想列出具有互联网访问权限的应用程序。
我有这个例子
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
}
}
但我不明白,这段代码将如何检查互联网许可?
谁能给出完整的例子???
谢谢。
how this code will check for internet permission?
通过检查 permission
以查看它是否是所需的值:
PackageManager p = context.getPackageManager();
final List<PackageInfo> apps = p.getInstalledPackages(PackageManager.GET_PERMISSIONS);
for (PackageInfo pkg : apps) {
for (String permission : pkg.requestedPermissions) {
if (Manifest.permission.INTERNET.equals(permission)) {
// do something
break;
}
}
}
本例填写packageNames
所有需要上网权限的应用包名:
ArrayList<String> packageNames = new ArrayList<String>();
PackageManager p = getPackageManager();
final List<PackageInfo> apps = p.getInstalledPackages(PackageManager.GET_PERMISSIONS);
for (PackageInfo packageInfo : apps) {
if (packageInfo.requestedPermissions == null)
continue;
for (String permission : packageInfo.requestedPermissions) {
if (TextUtils.equals(permission, android.Manifest.permission.INTERNET)) {
packageNames.add(packageInfo.packageName);
break;
}
}
}
我想列出具有互联网访问权限的应用程序。 我有这个例子
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
}
}
但我不明白,这段代码将如何检查互联网许可?
谁能给出完整的例子???
谢谢。
how this code will check for internet permission?
通过检查 permission
以查看它是否是所需的值:
PackageManager p = context.getPackageManager();
final List<PackageInfo> apps = p.getInstalledPackages(PackageManager.GET_PERMISSIONS);
for (PackageInfo pkg : apps) {
for (String permission : pkg.requestedPermissions) {
if (Manifest.permission.INTERNET.equals(permission)) {
// do something
break;
}
}
}
本例填写packageNames
所有需要上网权限的应用包名:
ArrayList<String> packageNames = new ArrayList<String>();
PackageManager p = getPackageManager();
final List<PackageInfo> apps = p.getInstalledPackages(PackageManager.GET_PERMISSIONS);
for (PackageInfo packageInfo : apps) {
if (packageInfo.requestedPermissions == null)
continue;
for (String permission : packageInfo.requestedPermissions) {
if (TextUtils.equals(permission, android.Manifest.permission.INTERNET)) {
packageNames.add(packageInfo.packageName);
break;
}
}
}