獲取手機中應用程式的包名
阿新 • • 發佈:2019-01-31
/*
* @Author Sun Ruichuan
*
* */
public ArrayList<HashMap<String, Object>> getItems(Context context) {
PackageManager pckMan = context.getPackageManager();
ArrayList<HashMap<String, Object>> items = new ArrayList<HashMap<String, Object>>();
List<PackageInfo> packageInfo = pckMan.getInstalledPackages(0);
for (PackageInfo pInfo : packageInfo) {
HashMap<String, Object> item = new HashMap<String, Object>();
item.put("appimage", pInfo.applicationInfo.loadIcon(pckMan));
item.put("packageName", pInfo.packageName);
item.put("versionCode", pInfo.versionCode);
item.put("versionName", pInfo.versionName);
item.put("appName", pInfo.applicationInfo.loadLabel(pckMan).toString());
items.add(item);
}
return items;
}
* @Author Sun Ruichuan
*
* */
public ArrayList<HashMap<String, Object>> getItems(Context context) {
PackageManager pckMan = context.getPackageManager();
ArrayList<HashMap<String, Object>> items = new ArrayList<HashMap<String, Object>>();
List<PackageInfo> packageInfo = pckMan.getInstalledPackages(0);
for (PackageInfo pInfo : packageInfo) {
HashMap<String, Object> item = new HashMap<String, Object>();
item.put("appimage", pInfo.applicationInfo.loadIcon(pckMan));
item.put("packageName", pInfo.packageName);
item.put("versionCode", pInfo.versionCode);
item.put("versionName", pInfo.versionName);
item.put("appName", pInfo.applicationInfo.loadLabel(pckMan).toString());
items.add(item);
}
return items;
}