1
我想显示在列表视图中对我的Android所有正在运行的应用程序,我的代码显示出所有运行的应用程序,但在某些流程被抛出异常,PacketManager名未找到错误
原因:包管理器未找到与例外messege android.process.acore and android.process.media.
我使用下面的代码:
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
}