android启用其他应用程序,杀死Android上的另一个应用程序?
我試圖殺死我的另一個應用程序。但是這段代碼無法殺死我的另一個應用程序。我知道殺死另一個應用程序是一個壞主意。但是我有一個學習的目的,并且我試圖殺死人。我的代碼部分:
Button runningApp = (Button) findViewById(R.id.runningApp);
runningApp.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
String nameOfProcess = "com.example.filepath";
ActivityManager? manager = (ActivityManager)ApplicationActivity.this.getSystemService(Context.ACTIVITY_SERVICE);
List listOfProcesses = manager.getRunningAppProcesses();
for (ActivityManager.RunningAppProcessInfo process : listOfProcesses)
{
if (process.processName.contains(nameOfProcess))
{
Log.e("Proccess" , process.processName + " : " + process.pid);
android.os.Process.killProcess(process.pid);
android.os.Process.sendSignal(process.pid, android.os.Process.SIGNAL_KILL);
manager.killBackgroundProcesses(process.processName);
break;
}
}
}
});
我添加了權限,它們是:
每當我看到LogCat時,特定的應用程序就會在后臺運行。我在哪里弄錯了?
總結
以上是生活随笔為你收集整理的android启用其他应用程序,杀死Android上的另一个应用程序?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android下音频采集功能,音频采集:
- 下一篇: android get请求最长字符串,a