Mark is right. Implementing a 'close box' under Android is a bad idea, because it is misleading to the user. The truth is that the Android OS does NOT support the notion of 'close' for apps. It implements a different paradigm, one more like SymbianOS (yechh!) than like Windows. The user leaves apps and enters others, but it is the system that decides to definitively CLOSE them, killing the hosting process.
Many Android apps really do follow this Symbian-like pattern, so it is reasonable to expect users to be used to it, even to prefer it in Android apps. Now I realize that many people have a spec from the client that asks for this close box. But in that case, the best procedure is to negotiate with the client, explaining why this is a bad idea, misleading to the users. If the client refuses to see the light, the closest you can get to a close box is to call Activity.finish() (on the current activity) after sending a message to all your other activities and possibly Services, BroadcastReceivers to do similarly (for a ordered Receiver this would be AbortBroadcast) But as Mark said, this is a bad idea. For one thing, "doing similarly" is not straightforward, since Services and BroadcatReceivers do NOT have a finish() method. And what about data connections? Are you going to have to shut down the ContentProviders too? Finally, look at the link Mark gave. It is a good explanation from a slightly different POV of why you should not do a close/exit box. On Sep 8, 5:16 am, Mark Murphy <mmur...@commonsware.com> wrote: > On Wed, Sep 7, 2011 at 11:27 AM, Ali Alyassen <omg...@gmail.com> wrote: > > i have a close button in my project so i want if any one press these > > button i want my app close > > Please don't. > > http://stackoverflow.com/questions/2033914/quitting-an-application-is... > > -- > Mark Murphy (a Commons > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy > > Android Training in Oslo:http://bit.ly/fjBo24 -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en