I want to get all the tasks that are running in android.I found getRunningTasks in ActivityManager but from android-5.0 the getRunningTasks may not give all the tasks (in my
Use this code
Its works for me. Dont forgot to use ListView
in your Xml
File.
ListView listView = (ListView) findViewById(R.id.listview);
ActivityManager actvityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
List procInfos = actvityManager.getRunningAppProcesses();
String[] values = new String[procInfos.size()];
final String packageName = "my.application.package";
PackageManager packageManager = getApplicationContext().getPackageManager();
for (int i = 0; i < procInfos.size(); i++) {
values[i] = procInfos.get(i).processName;
}
ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, values);
listView.setAdapter(adapter);