How to quit android application programmatically

前端 未结 30 2722
迷失自我
迷失自我 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:35

    Easy and simple way to quit from the application

    Intent homeIntent = new Intent(Intent.ACTION_MAIN);
    homeIntent.addCategory(Intent.CATEGORY_HOME);
    homeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(homeIntent);
    

提交回复
热议问题