I am trying to display all running apps on my android in a list view, my code is showing all running apps but in some processes it is throwing exception,
cause: Package Manager not found with exception messege android.process.acore and android.process.media.
I am using below code:
while(i.hasNext())
{
ActivityManager.RunningAppProcessInfo info = (ActivityManager.RunningAppProcessInfo)(i.next());
try {
CharSequence c = pm.getApplicationLabel(pm.getApplicationInfo(info.processName, PackageManager.GET_META_DATA));
Process[j] = c.toString();
ListAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Process);
ListView ProcessList = (ListView) findViewById(R.id.list);
ProcessList.setAdapter(adapter);
}
catch(Exception e)
{
System.err.println("Caught Exception: "
+ e.getMessage());
//Name Not FOund Exception
}
I am using the given blow code of running task of the device use it: