我在下面有这段代码:
package com.example.killall;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
//import android.widget.TextView;
import android.app.ActivityManager;
public class MainKill extends Activity {
private Button BprocessesKill ;
//private TextView processesKill;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_kill);
final ActivityManager am=(ActivityManager) getSystemService("SYSTEM_ACTIVITY");
BprocessesKill=(Button) this.findViewById(R.id.BkillProcesses);
//processesKill=(TextView) this.findViewById(R.id.killProcesses);
BprocessesKill.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
am.killBackgroundProcesses(getPackageName());
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main_kill, menu);
return true;
}
}
我想要做的只是按下按钮并杀死所有后台进程。我对这段代码的问题是,当我按下按钮时,它会向我显示消息:不幸的是,KillAll(那是我的应用程序的名称)已经停止。我应该改变什么?