2012-08-06 64 views

回答

2

嘗試使用ActivityManager

try 
{ 
    List<ActivityManager.RunningAppProcessInfo> tasks = am.getRunningAppProcesses(); 
    int numOfTasks = tasks.size(); 
    for(int i = 0; i < numOfTasks; i++) 
    { 
     ActivityManager.RunningAppProcessInfo task = tasks.get(i); 
     try 
     { 
      PackageInfo myPInfo = getPackageManager().getPackageInfo(task.processName, 0); 
      //System.out.println(task.processName); 
     } 
     catch (PackageManager.NameNotFoundException ne) 
     { 
     ne.printStackTrace(); 
     } 
    } 
} 
catch (SecurityException se) 
{ 
se.printStackTrace(); 
} 

還看到:http://smartandroidians.blogspot.com/2011/05/way-to-check-whether-application-is.html

相關問題