Killing all the activities that was started by my application.

by Ajmer Singh » Wed, 08 Sep 2010 15:41:48 GMT


Sponsored Links
 Hi

I need to have a "Exit" menu items in my application,My question here is how
can i just exit the app,Please throw some light on this is that possible in
android if yes then how.

Please help,Thanks in advance

-- 
Thanks and Regards
Ajmer Singh

--



Killing all the activities that was started by my application.

by TreKing » Wed, 08 Sep 2010 16:16:38 GMT


 



Why do you think you need this?



Have the user press the back button.



Normally, you should let the user and Android take care of closing / killing
your Activity.

-------------------------------------------------------------------------------------------------
TreKing < http://sites.google.com/site/rezmobileapps/treking> ; - Chicago
transit tracking app for Android-powered devices

--


Sponsored Links


Killing all the activities that was started by my application.

by Yahel » Wed, 08 Sep 2010 18:26:02 GMT


 Every one here will tell you, you don't need it, it's against Android
Os policy. Android manage the life and death of your app.

But anyway : you should simply call the finish() function of your
activity : It will call onpause, onstop, and ondestroy thus
terminating gracefull the app.
You need to do your own cleanup if you have more than one activity
though.

Good luck.

Yahel




--



Killing all the activities that was started by my application.

by viktor » Wed, 08 Sep 2010 22:39:07 GMT


 Yahel is right, it is very dangerous.

But you can try doing it with broadcast, and listen it in activities
which you want to close.

If you did, look at device CPU status. Maybe your devise is down!!!

Or another way is saving your own activity stack, and consequentially
finish.

--



Killing all the activities that was started by my application.

by Ajmer singh » Wed, 08 Sep 2010 23:04:12 GMT


 Thanks for your reply

I have another question regarding that, How can i put the already running
activity in the background to the foreground,
For example : if i have started Activity A then i started other Activity B
Then Activity A should be sent to background Then how can i bring back
Activity A to foreground(With using the Back button).





>



Killing all the activities that was started by my application.

by Mark Murphy » Wed, 08 Sep 2010 23:09:22 GMT


 


Call finish(), which will destroy B and bring A back to the foreground.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://github.com/commonsguy 
 http://commonsware.com/blog  |  http://twitter.com/commonsguy 

Android Training in London:  http://skillsmatter.com/go/os-mobile-server 

--



Killing all the activities that was started by my application.

by Indicator Veritatis » Thu, 09 Sep 2010 01:55:39 GMT


 Both your previous question and your current question show that you
did not pay enough attention to learning the fundamentals of Android
before you started coding. You must not only read, but study
 http://developer.android.com/guide/topics/fundamentals.html especially 
the section on Component Lifecycles, 
 http://developer.android.com/guide/topics/fundamentals.html #lcycles

For the answer is the same: you do not do this, you let the system do
it for you. Now the system generally will do this for you when you
send an Intent from the one Activity to the other, but it is still the
system that makes the final decision. And you have to do the right
thing in all your lifecycle-related callbacks for this to work.




> >



Killing all the activities that was started by my application.

by Indicator Veritatis » Thu, 09 Sep 2010 02:06:56 GMT


 But he didn't say he wanted to destroy A. He said "A should be sent to
background[sic]". So your proposal, good though it is, might not be
the right answer. That is why I am saying he has to study
 http://developer.android.com/guide/topics/fundamentals.html #lcycles so
that he has the background to no longer confuse 1) what he wants to do
with 2) how it is best done. For it is clear that he really does not
understand how to design Activities to work well with Android
lifecycle management. He is asking for how to do the wrong things.

After all, maybe he should go ahead and do it your way, destroying A.
In fact, this is likely, even if it does force him to rethink his
design. But if he really does require A to go to the background, then
he will have to start up B some other way, such as sending it an
Intent. But then when SHOULD he destroy A? It has to be done sometime,
but we can't say when. If he doesn't have a good answer to this
question either, then that is another strong hint that he should go
ahead and do it your way, destroying A and recreating it when needed.






--



Killing all the activities that was started by my application.

by Frank Weiss » Thu, 09 Sep 2010 02:14:48 GMT


 


I suppose this depends on what activity B does and its relationship to
activity A. In most cases, the user would press the back button to dismiss
activity B and the OS would return activity A to the foreground.

--



Killing all the activities that was started by my application.

by Indicator Veritatis » Thu, 09 Sep 2010 14:36:33 GMT


 But as M. Murphy rightly pointed out, 'dismiss' here cannot mean
merely "send to the background"; it means "cause the system to destroy
the activity". That is not the same. Whether the difference is
relevant to the OP is a question the OP must answer. We cannot answer
it for him.






--



Other Threads

1. How do I navigate to the program data with adb shell

On a real phone this will work with ROM with root access.




-- 

2. Why RIL.java implements CommandInterface twice

Maybe this group is not the right one to ask this question.

I am studying RIL and noticed RIL.java inplements CommandInterface
twice( extend BaseCommand implement CommandInterface). What is it
for?
Any design pattern here?

Best Regards
James

-- 

3. How to know the caller of ContentProvider

4. When call mWifiManager.isWifiEnabled , it crash. thanks in advance.

5. G. Checkout Declined Payments

6. AlertDialog.show() leaks when phone rotates

7. Set ringtone from raw resource?