0

ホーム画面の onBackPressed() で System.exit() を使用したアプリがありますが、実際にはアプリを閉じても forceClose が得られません。

Home.Class

 @Override
    public void onBackPressed() {
        super.onBackPressed ();
        System.exit (0);
    }  
4

5 に答える 5

0

finish()の代わりにメソッドを使用System.exit (0);

于 2014-06-27T09:34:05.613 に答える
0

finish()の代わりに使用しSystem.exit(0)ます。

于 2014-06-27T09:34:13.273 に答える
0

このコードを試してください

 @Override
public void onBackPressed() {
    super.onBackPressed();
      if (backpressvalue == 0) {
      Intent intent = new Intent(ControlScreen.this, MyCameras.class);
      finish();
      }
}
于 2014-06-27T09:55:01.827 に答える
0

新しい活動を開始した後、現在の活動を終了することを提案しました

例えば ​​:

//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.
}
于 2014-06-27T09:46:30.047 に答える
0

System.exit(0) または finish() はアプリを閉じず、現在のアクティビティを終了し、最後のアクティビティに移動します。

アプリを終了したい場合は、これを試してください

android.os.process.killProcess(android.os.process.myPid()); 

詳細については、このリンクを参照してください

于 2014-06-27T09:37:59.060 に答える