How to get installed applications in Android and no system apps?

后端 未结 4 435
梦毁少年i
梦毁少年i 2020-12-13 01:05

I want to get all application which appears in the menu screen. But, now I only get the user installed apps or all the application (included the system application).

<
4条回答
  •  长情又很酷
    2020-12-13 01:43

    Below code will give you all the system apps related to Operating System. This will not include Apps like YouTube, Gmail, etc


    try {
        ApplicationInfo ai =  getPackageManager().getApplicationInfo(item.packageName, 0);
        if ((ai.flags & ApplicationInfo.FLAG_SYSTEM ) != 0) {
          if((ai.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP ) == 0) {
            appItem.setSystemApp(true);
            Mylog.v("System Apps " + appItem.getAppName());
          }
        }
      } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
      }
    

提交回复
热议问题