如何找到在Android中安装的应用程序? [英] How to find installed applications in android?

查看:198
本文介绍了如何找到在Android中安装的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想安装在Android的第三方应用程序的名称和包名。 我已经试过,但我得到的所有应用程序的名称(第三方和pre安装)。

I want to get the name and package name of a third party application installed in android. I have tried but i got the name of all applications(third party and pre installed).

我如何能够确定应用程序是否是系统应用程序或其他应用程序?

How can i identify whether an application is a system application or an other application?

推荐答案

这将这样的伎俩...干杯:)

This will do the trick...cheers :)

PackageManager pm = getPackageManager();
List<PackageInfo> list = pm.getInstalledPackages(0);

for (PackageInfo pi : list) {
   ApplicationInfo ai;
   try {
      ai = pm.getApplicationInfo(pi.packageName, 0);
      System.out.println(">>>>>>packages is<<<<<<<<" + ai.publicSourceDir);

      // this condition if satisfied means the application currently refered by ai
      // variable is
      // a system application
      if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
         Log.d(getClass().getSimpleName(), ">>>>>>packages is system package" + pi.packageName);
       }
    } catch (NameNotFoundException e) {
        Log.d(getClass().getSimpleName(), "Name not found", e);
    }
}

这篇关于如何找到在Android中安装的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆