I am creating a method to displays the installed applications in android. I gave the following lines of code to get the application list
PackageManager packageManager=this.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)) //checking if the package is having INTERNET permission
{
//some processing
}
}
}
Here everything is working fine but the list includes the system packages too. I need to get only the list of user installed packages. Is there any way to do??
What flag should we set in getInstalledPackages() to get the user installed packages?
The
ApplicationInfoobject will haveFLAG_SYSTEMif it is installed on the firmware, so you can use that to filter those out.