Plain's Blog

休想打败我的生活🔥

  1. 1. 作用
  2. 2. 代码

作用

通过PackageManager来获取手机应用信息

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
private void getApplicationList() {

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

for (int i = 0; i < list.size(); i ++){

PackageInfo packageInfo = list.get(i);

//过滤系统应用
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) ==0){
Log.d(TAG, i + ": --- > Name: " + packageInfo.applicationInfo.loadLabel(pm).toString() + " --- > packageName: " + packageInfo.packageName);
}

}

}

本文作者 : Plain
This blog is under a CC BY-NC-SA 3.0 Unported License
本文链接 : https://plain-dev.com/android-get-app-list/

本文最后更新于 天前,文中所描述的信息可能已发生改变