申请时间和名称已开启
final PackageManager pm = getPackageManager();
packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
for(ApplicationInfo packageInfo : packages )
{
String name=packageInfo.getClass().getName();
Toast.makeText(ListActivity.this, ""+ name, 0).show();
}

答案 0 :(得分:2)
尝试此操作以获取正在运行的应用列表。
ActivityManager activity_manager = (ActivityManager) context.getSystemService(Activity.ACTIVITY_SERVICE);
使用getRunningTasks()
中的ActivityManager
方法。
final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
final List<RunningTaskInfo> recentTasks = activityManager.getRunningTasks(Integer.MAX_VALUE);
for (int i = 0; i < recentTasks.size(); i++)
{
Log.d("Executed app", "Application executed : " +recentTasks.get(i).baseActivity.toShortString()+ "\t\t ID: "+recentTasks.get(i).id+"");
}
在清单文件中添加此权限。
<uses-permission android:name="android.permission.GET_TASKS" ></uses-permission>