过滤掉安卓中来自原始设备制造商的不需要的系统应用程序。

huangapple go评论66阅读模式
英文:

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.flagspackage.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 around 15-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 and package.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&lt;ApplicationInfo&gt; thirdPartyApps = new ArrayList&lt;&gt;();
PackageManager pm = getPackageManager();
List&lt;ApplicationInfo&gt; 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
    }
}

huangapple
  • 本文由 发表于 2020年8月24日 20:06:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/63560713.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定