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
}