2014-03-27 114 views
0

我想開發關閉當前正在運行的應用程序的此類應用程序。在android中以編程方式關閉所選應用程序

我嘗試下面的代碼:

 ActivityManager actvityManager = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE); 
       List<RunningAppProcessInfo> procInfos = actvityManager.getRunningAppProcesses(); 

       for(RunningAppProcessInfo runningProInfo:procInfos){ 


         if(runningProInfo.processName.equals("com.teamviewer.quicksupport.market")){ 
          System.out.println("Running Processes"+ "()()"+runningProInfo.processName); 

           android.os.Process.killProcess(runningProInfo.pid); 
          // ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); 
          // actvityManager.killBackgroundProcesses(runningProInfo.processName); 
         } 
     } 

但不工作。

有沒有辦法從我的android應用程序關閉其他應用程序,沒有root權限。

請幫幫我。

+0

http://stackoverflow.com/questions/10991421/how-to-close-entire-application – Android

回答

0

嘗試ActivityManager.killBackgroundProcesses()。但是,它只會殺死後臺進程,而不是前臺進程。如果任何應用程序可能會殺死任何其他應用程序,尤其是用戶當前正在使用的應用程序,那將會是一個安全問題

相關問題