Contents
  • 如何检测手机内装了什么APP?

    相关类

    • PackageManager
    • ApplicationInfo
    • ResolveInfo
    • ApplicationInfo与ResolveInfo区别:
      前者能够得到Icon、Label、meta-data、description。后者只能得到Icon、Label。
      前者得到的Label 包括Server、provider等。

      1.PackageManager 获取手机中所有应用的包的信息。通过getPackageManager()方法得到。
      2.ApplicationInfo 通过配置文件里标签 得到应用的信息。
      3.ResolveInfo 通过配置文件里的标签 得到应用的信息。

例子:

        PackageManager manager = getPackageManager();  
        1. List<ApplicationInfo> appInfos = manager.getInstalledApplications(0);  
        ApplicationInfo有如下方法:  
        loadDescription、loadLabel、loadIcon、loadLogo

        //通过Intentfilter筛选  
        2. Intent intent = new Intent(Intent.ACTION_MAIN, null);  
        intent.addCategory(Intent.CATEGORY_LAUNCHER);  
        List<ResolveInfo> reInfos = manager.queryIntentActivities(intent, 0);  
        ResolveInfo有如下方法:    
        loadLabel、loadIcon
        //loadLabel就是获得程序名
Contents