How to quit android application programmatically

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

    This may be very late and also as per the guidelines you're not supposed to handle the life cycle process by yourself(as the os does that for you). A suggestion would be that you register a broadcast receiver in all your activities with "finish()" in their onReceive() & whenever you wish to quit you can simple pass an intent indicating that all activities must shut down..... Although make sure that you do "unregister" the receiver in your onDestroy() methods.

提交回复
热议问题