1) https://github.com/jaredrummler/AndroidProcesses
2) https://www.android-examples.com/get-show-all-background-running-process-in-android/
2) https://www.android-examples.com/get-show-all-background-running-process-in-android/
//1)// final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);// final List<ActivityManager.RunningTaskInfo> recentTasks = activityManager.getRunningTasks(Integer.MAX_VALUE);//// for (int i = 0; i < recentTasks.size(); i++)// {// Toast.makeText(this,"Application executed : " +recentTasks.get(i).baseActivity.toShortString()+ "\t\t ID: "+recentTasks.get(i).id+"",Toast.LENGTH_LONG).show();// Log.e("Executed app::", "Application executed : " +recentTasks.get(i).baseActivity.toShortString()+ "\t\t ID: "+recentTasks.get(i).id+"");// }//2// ActivityManager actvityManager = (ActivityManager)// this.getSystemService( ACTIVITY_SERVICE );// List<ActivityManager.RunningAppProcessInfo> procInfos = actvityManager.getRunningAppProcesses();//// for (int i = 0; i < procInfos.size(); i++){// Toast.makeText(this,"Application executed : " +procInfos.get(i).processName + "\t\t ID: "+procInfos.get(i).pid+"",Toast.LENGTH_LONG).show();// Log.e("Executed app::", "Application executed : " +procInfos.get(i).processName + "\t\t ID: "+procInfos.get(i).pid+"");////// }//3 ActivityManager activityManager = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningTaskInfo> tasks = activityManager.getRunningTasks(Integer.MAX_VALUE); final PackageManager pm = getApplicationContext().getPackageManager(); ApplicationInfo ai; for (ActivityManager.RunningTaskInfo task : tasks) { try { ai = pm.getApplicationInfo(task.baseActivity.getPackageName(), 0); } catch (final PackageManager.NameNotFoundException e) { ai = null; } String applicationName = (String) (ai != null ? pm.getApplicationLabel(ai): "(unknown)"); Toast.makeText(this,"Application executed : " +applicationName,Toast.LENGTH_LONG).show(); Log.e("Executed app::", "Application executed : " +applicationName); // }
No comments:
Post a Comment