我得到了正确在设备上运行的应用列表:
ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
List<ActivityManager.RunningServiceInfo> services = activityManager.getRunningServices(99);
ActivityManager am = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
List l = am.getRunningAppProcesses();
但是有了这个,我得到了完整的包名:
com.google.process.location, com.whatsapp
我还使用了分割功能
for (String aa1 : risky_arr) {
String[] splits = aa1.split(" ");
String aa2 = (splits[1].substring(0, splits[1].length()-1));
hashSet.add(aa2);
}
但它也缩短了我上面说的长度。
所以我的问题是,我怎样才能获得像Whatsapp,location,paisa,swipe等应用名称。
答案 0 :(得分:0)
使用以下代码获取应用名称:
ResolveInfo packageInfo = mApps.get(position);
PackageManager pm = getActivity().getPackageManager();
appName = new String(packageInfo.loadLabel(pm).toString());