我正在尝试此方法,但已过时。
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> tasks = activityManager.getRunningTasks(Integer.MAX_VALUE);
for (int i = 0; i < tasks.size(); i++) {
Log.e("Running task", "Running task: " + tasks.get(i).baseActivity.toShortString() + "\t\t ID: " + tasks.get(i).id);
}
答案 0 :(得分:0)
这是获取所有已安装应用程序列表的简便方法
final PackageManager pm = getPackageManager();
//get a list of installed apps.
List<ApplicationInfo> packages =
pm.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo packageInfo : packages) {
Log.d(TAG, "Installed package :" + packageInfo.packageName);
Log.d(TAG, "Source dir : " + packageInfo.sourceDir);
Log.d(TAG, "Launch Activity :" +
pm.getLaunchIntentForPackage(packageInfo.packageName));
}
答案 1 :(得分:-1)
您可以尝试以下方法:
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> pkgAppsList =
context.getPackageManager().queryIntentActivities( mainIntent, 0);