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. ClassLoader.isAncestorOf(ClassLoader) Bug

Hello All,

Please someone from Google to comment this issue!

My colleagues has found a bug in the java.lang.ClassLoader
implementation of the cupcake tag of the Android platform. Here is a
short descriptions:

We try to invoke ClassLoader.getSystemClassLoader() in one of our OSGi
implementation classes and afterwards we have endless loop. Here are the
bodies of the methods:

public static ClassLoader getSystemClassLoader() {
  SecurityManager smgr = System.getSecurityManager();

  if (smgr != null) {
    ClassLoader caller = VMStack.getCallingClassLoader();
    if (caller != null && !caller.isAncestorOf(SystemClassLoader.loader)) {
      smgr.checkPermission(new RuntimePermission("getClassLoader"));
    }
  }
  return SystemClassLoader.loader;
}
...
and in isAncestorOf method we have:

final boolean isAncestorOf(ClassLoader child) {
  for (ClassLoader current = child; current != null; current =
child.parent) {
    if (current == this) {
      return true;
    }
  }
  return false;
}

In a dynamic environment like an OSGi implementation with set security
manager the isAncestorOf(...) follows to an endless loop. As you can see
- if the child is a custom class loader, which has another class loader
as a parent. The problem is that current is always is set to
child.parent but the child is never changed. The following code fixes
the problem:

final boolean isAncestorOf(ClassLoader child) {
  for (ClassLoader current = child; current != null; current =
current.parent) {
    if (current == this) {
      return true;
    }
  }
  return false;
}

I hope that you will be able to fix this as soon as possible and to
update the cupcake branch too. Please notify me when this is ready.

Thanks in advance!!

-- 

Best Regards,
    Daniel
---------------------------------------------------------------
Daniel Janev  Department Manager/Core Platform and Smart Home
ProSyst Software GmbH
1606 Sofia, Bulgaria  Vladajska Str. 48
Tel. +359 (0)2 952 35 81/109  Fax +359 (0)2 953 26 17
Mobile Phone +359 (0)888 678 670
http://www.prosyst.com  d.ja...@prosyst.com
---------------------------------------------------------------
stay in touch with your product.
---------------------------------------------------------------

--~--~---------~--~----~------------~-------~--~----~

2. Android and Special Chars?

I created small rss reader application using DocumentBuilder class.
Everything works fine, but when Title and/or Description elements of
specific feed contains char  " , it cuts off all text after that char.

example:

if original text is -> This is "text"
then i get this    -> This is "

I have checked parser inside standard Java console application and in
it, everything works fine with the text under quotation (e.g. "Example
text"). What could be the problem? I put Title text inside a ListView
and description text inside TextView and it somehow cuts off text
after " !?

Please help, this is almost impossible to debug... :(
--~--~---------~--~----~------------~-------~--~----~

3. When is the Android Market available in the EU?

4. Opencore (WAS Outstanding cupcake -> master merge)

5. adb and ddms can't connect to emulator after installing Windows XP driver for G1

6. How can my application be intimated whenever i edit my contact list

7. Please help in getting screen coordinates of a view