get list of application which have internet permission in android

I want to list of application which have internet access permission. I have this example

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
}
}

but i am not getting this, how this code will check for internet permission?

can someone give full example???

thank you.

Answers


This example fills packageNames with all the package name of the apps that require the internet permission:

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;
        }
    }
}

how this code will check for internet permission?

By checking permission to see if it is the desired value:

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;
        }
    }
}

Need Your Help

Can I do a mysql Select, Update and Delete in one query?

mysql select sql-delete

Can I say that one of many ways to optimize mysql is to reduce the number of queries?

How to create Bold data in MySQL database text field?

mysql html text-formatting

Is it possible to create bold text in a MySQL database text table field?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.