我不知道为什么Runtime.getRuntime()。exec(“kill -9”+ PID)不起作用,但是使用adb.exe shell它可以很好地工作......!
OnClickListener killButtonListner = new View.OnClickListener() {
public void onClick(View v) {
try {
Process ps = Runtime.getRuntime().exec("kill -9 " + PID);
Toast.makeText(getBaseContext(),"Process killed" , Toast.LENGTH_SHORT).show();
} catch (IOException e) {
Toast.makeText(getBaseContext(),e.getMessage().toString(),Toast.LENGTH_SHORT).show();
}
}
};
killButton.setOnClickListener(killButtonListner);
}