开发者

How to exit an application completely in ANDROID

I have an application.In tha开发者_运维问答t if we press on home button app closes but when i launch the app it resumes where i stopped.I mean it do not closed completely.how to solve this problem.


When you press Home button, onDestroy method of the current activity is called. You can perform any shutdown operations there. Design of Android doesn't have a concept of explicit application shutdown, so that the user can continue on the same activity where he started.

You are trying to copy desktop application behavior (the application is shutdown explicitly) to Android with different usage patterns. While this is understandable, in most cases this will contradict to other applications behavior and will annoy users. So if you have anything to shutdown, do this in onDestroy method.


You can make your android app return to the root activity each time you open it by modifying your AndroidManifest.xml to include

android:clearTaskOnLaunch="true"

in the desired <activity> declaration.


Android does not allow you to terminate the application at any time. Application lifecycle is maintained by the Android OS itself. You are not supposed to meddle with it. Unlike desktop applications, Android application lifetime is determined by the OS itself. You can only end an activity.

For more Info refer to this bug http://code.google.com/p/android/issues/detail?id=1572


You need to call finish() in your onDestroy() method.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜