ここで 1 つのアプリケーションを実行しています。ボタンをクリックすると終了ボタンが 1 つあります。そのときは、アプリケーションを終了する必要があります。以下のコードを使用してみましたアプリを閉じるだけでなく、タスクマネージャーから削除する必要があります。
public class MainMenu extends Activity {
Button exit;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainmenu);
exit=(Button)findViewById(R.id.btn1);
exit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
});
}
}