0

I am trying to close a whole stack of activities using the way described here:

How to kill an application with all its activities?

Namely, each activity starts the other one with startActivityForResult, and in onActivityResult calls finish() to close itself together with the activity it opened.

The problem is that the activities in the task still seem to repaint themselves at least once before they close, and this doesn't look good. After closing the topmost activity one sees all previously opened activities like in a very fast slideshow.

How can one avoid this graphical issue?

EDIT: I need that if the user presses HOME button and then presses the app's icon in launcher, he returns to the current state of the stack, not to the very first activity again. So, from what I understand, with such a requirement I can't finish() activities before starting next ones.

Community
  • 1
  • 1
iseeall
  • 3,381
  • 9
  • 34
  • 43

2 Answers2

1

That's native behaviour, intended to aid in user Experience. When an Activity is started with startActivityForResult and then finishes, it will (on devices that allow fancy animations) automatically slide away. That helps people not get surprised by the screen suddenly changing.

You could try starting the Activities without startActivityForResult and handling the passing of data to and from Activities manually, then handle how/when Activities finish() and which Activity they pass back to. You might find you implement something where Activities actually pass forward to the appropriate Activity all the time, rather than back to an Activity on the stack.

straya
  • 5,002
  • 1
  • 28
  • 35
  • +1 to the info: "When an Activity is started with startActivityForResult and then finishes, it will (on devices that allow fancy animations) automatically slide away." startActivity doesnt? – Marcos Vasconcelos Aug 06 '13 at 17:27
0
Intent intent = new Intent();
                intent.setClass(getApplicationContext(),
                        PhoneListCheckboxAES.class);
                 intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
                finish();

If u give like this when u are starting the next activity then the graphical problems won't occur

user1203673
  • 1,015
  • 7
  • 15
  • Is there a way to do this without calling finish() on itself? Because of course if you call finish(), the will be no stack of activities and no graphical issues. But I need that if the user presses HOME button and then comes back, he returns to the current state of the stack, not the very first activity again. – iseeall Feb 25 '12 at 23:32