英文:
To filter out unwanted system apps from the OEM in android
问题
Sure, here's the translation of your provided content:
如何获取在我的 RecyclerView
中的非系统应用程序列表?
我想要对列表进行过滤,不包括系统应用程序。
- 当前系统应用程序的数量为
353
,但应该大约为15-20
个。 - 我已经使用了
packageManager.getInstalledPackages(0)
来获取设备中安装的所有包,并且为了区分系统应用程序和第三方应用程序,我使用了applicationInfo.flags
和package.ApplicationInfo.FLAG_SYSTEM)==0
。 - 这里是一个截图链接。
请帮忙!
无论是 java
还是 kotlin
,都非常感谢。
提前感谢!😊
英文:
How can I get a list of non-system apps for my RecyclerView
?
I want to filter my list not to include system apps
- The current app count for system apps is
353
but it should be around15-20
- I have used
packageManager.getInstalledPackages(0)
to get the all the installed packages in the device and to differentiate between system apps and third party apps i have used
applicationInfo.flags
andpackage.ApplicationInfo.FLAG_SYSTEM)==0
- Here is a ScreenShot
Please help!!
Any language, java
or kotlin
is appreciated.
THANKS IN ADVANCE..😃
答案1
得分: 2
非系统应用可以通过具有“启动意图”来识别。
如果应用没有启动意图,则为系统应用检查
ArrayList<ApplicationInfo> thirdPartyApps = new ArrayList<>();
PackageManager pm = getPackageManager();
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo packageInfo : packages) {
if (pm.getLaunchIntentForPackage(packageInfo.packageName) != null) {
String currAppName = pm.getApplicationLabel(packageInfo).toString();
// This app is a non-system app
thirdPartyApps.add(packageInfo);
} else {
// System App
}
}
英文:
Non systems apps can be identified by having a launch intent
if the app has no launch intent then its a system app check
ArrayList<ApplicationInfo> thirdPartyApps = new ArrayList<>();
PackageManager pm = getPackageManager();
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
for(ApplicationInfo packageInfo:packages){
if( pm.getLaunchIntentForPackage(packageInfo.packageName) != null ){
String currAppName = pm.getApplicationLabel(packageInfo).toString();
//This app is a non-system app
thirdPartyApps.add(packageInfo);
}
else{
//System App
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论