Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get application permission settings in android?

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?

like image 906
Unnikrishnan Avatar asked Jan 19 '23 03:01

Unnikrishnan


1 Answers

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.

like image 158
Suchi Avatar answered Jan 29 '23 08:01

Suchi