Reputation: 501
I am developing a small application which lists only those application which connects to internet. How can I read the android manifest file from the Packageinfo class to access the permission settings of each application programmatically?
private void getWebApps() {
// TODO Auto-generated method stub
PackageManager packageManager=this.getPackageManager();
List<PackageInfo> applist=packageManager.getInstalledPackages(0);
Iterator<PackageInfo> it=applist.iterator();
while(it.hasNext()){
PackageInfo pk=(PackageInfo)it.next();
String appname=pk.applicationInfo.loadLabel(packageManager).toString();
installedapplist.add(appname);
}
In the above code "installedapplist" is an arrayList which stores the apps names. But before adding to the list I need to check only those application which access the internet. Can anyone help me how to check the permission?
Upvotes: 4
Views: 4613
Reputation: 10039
You could use -
getPackageManager().getInstalledPackages(PackageManager.GET_PERMISSIONS);
This returns an array of permissions. You could then iterate through it and check if the Internet one exists.
Upvotes: 7