File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to stop all activities and exit from android application

 
Satchidananda Mohanty
Ranch Hand
Posts: 78
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there !!

I wanted to stop all the activities and exit from my current android application. Can you suggest any better way to handle this.


Thanks in advance.
 
Mohan Prasath
Ranch Hand
Posts: 38
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While invoking your child activity you have to set the following flag to your intent. FLAG_ACTIVITY_CLEAR_TOP - this tag gives importance to the
intent to be started and removes all other activities in the stack.

Note : Also set FLAG_ACTIVITY_SINGLE_TOP in the list of flags.
 
Anurag Verma
Ranch Hand
Posts: 165
Hibernate Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is System.exit(0) not a good option for this?
 
Mohan Prasath
Ranch Hand
Posts: 38
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are many reasons why GC usage is not promoted.
1. The use of System.gc() is often considered to be inefficient code. Technically System.gc() works when there is anything to be garbaged. (This is my personal opinion and a general knowledge from my work experience)
2. You can't actually say what it does with the memory when you call it. And technically Java Heap space does not depend upon Java Memory Allocations.
3. As mentioned Google IO 2011, GC usage has to be avoided. Memory Management in Android
 
Satchidananda Mohanty
Ranch Hand
Posts: 78
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Mr. Mohan,
Let me try this.
 
Tim Moores
Bartender
Pie
Posts: 2488
4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can call finish() from with the main Activity to exit.

I doubt that calling System.gc() is even allowed, but it would indeed be a bad choice, as the app doesn't get a chance to clean up properly.
 
Satchidananda Mohanty
Ranch Hand
Posts: 78
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Finish() only finishes that current Activity and moves back to the previous Activity.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic