[英]How to filter user installed application in Android?
I am creating a method to displays the installed applications in android. 我正在创建一种方法来显示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? 我们应该在getInstalledPackages()中设置什么标志来获取用户安装的软件包?
如果已将ApplicationInfo
对象安装在固件上,则它将具有FLAG_SYSTEM
,因此您可以使用它来过滤掉那些对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.