ホーム画面の onBackPressed() で System.exit() を使用したアプリがありますが、実際にはアプリを閉じても forceClose が得られません。
Home.Class
@Override
public void onBackPressed() {
super.onBackPressed ();
System.exit (0);
}
ホーム画面の onBackPressed() で System.exit() を使用したアプリがありますが、実際にはアプリを閉じても forceClose が得られません。
Home.Class
@Override
public void onBackPressed() {
super.onBackPressed ();
System.exit (0);
}
finish()
の代わりにメソッドを使用System.exit (0);
finish()
の代わりに使用しSystem.exit(0)
ます。
このコードを試してください
@Override
public void onBackPressed() {
super.onBackPressed();
if (backpressvalue == 0) {
Intent intent = new Intent(ControlScreen.this, MyCameras.class);
finish();
}
}
新しい活動を開始した後、現在の活動を終了することを提案しました
例えば :
//MainActivity
{
//somecode there
startActivity(new Intent(MainActivity.this,SecondActivity.class)); //start a new activity
finish();// finish the activity so that when you press the backbutton it exits the app.
}
System.exit(0) または finish() はアプリを閉じず、現在のアクティビティを終了し、最後のアクティビティに移動します。
アプリを終了したい場合は、これを試してください
android.os.process.killProcess(android.os.process.myPid());
詳細については、このリンクを参照してください