Get application names with specific permission
- by rolling.stones
I want list of all applications installed on the device which use a specific permission like INTERNET.
i am using this code , but not able to retrieve results , please help .
private ArrayList<String> getInstalledApps(Context context) {
ArrayList<String> results = new ArrayList<String>();
PackageManager packageManager = context.getPackageManager();
List<PackageInfo> applist = packageManager.getInstalledPackages(0);
Iterator<PackageInfo> it = applist.iterator();
while (it.hasNext()) {
PackageInfo pk = (PackageInfo) it.next();
if (PackageManager.PERMISSION_GRANTED == packageManager.checkPermission(Manifest.permission.INTERNET, pk.packageName))
results.add("" + pk.applicationInfo.loadLabel(packageManager));
}
for (int i = 0; i <= results.size(); i++) {
Log.v("app using internet = ", results.toString());
}
return results;
}
Thanks in advance.
Any help accepted :)