开发者

Android app exit, which Mechanism to use?

following are the ways to exits from the application

 1. ActivityObject.finish();
 2. Runtime.getRuntime().exit(0);

I want to know which way is to be used & when ?

if there is another way please let 开发者_开发百科me know

Thanks in advance. Shrenik


That's usually not a good idea at all to "exit" an application in android. That's against Android nature. Read this topic first before doing something like that.


Look at this life cycle of an Android activity:

Android app exit, which Mechanism to use?

And the description of the OnDestroy state:

The final call you receive before your activity is destroyed. This can happen either because the activity is finishing (someone called finish() on it, or because the system is temporarily destroying this instance of the activity to save space. You can distinguish between these two scenarios with the isFinishing() method.

So calling ActivityObject.finish() is the right way to do it.


call moveTaskToBack(true) on your Activity

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜