How to quit android application programmatically

前端 未结 30 2101
迷失自我
迷失自我 2020-11-22 03:06

I Found some codes for quit an Android application programatically. By calling any one of the following code in onDestroy() will it quit application entirely?

30条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-22 03:21

    There is no application quitting in android, SampleActivity.this.finish(); will finish the current activity.

    When you switch from one activity to another keep finish the previous one

    Intent homeintent = new Intent(SampleActivity.this,SecondActivity.class);
    startActivity(homeintent);
    SampleActivity.this.finish();
    

提交回复
热议问题