0

Android's singleInstance launchMode seems to do what I want for the main tasks of my application, which is to keep the state of that Activity whenever I navigate back to it from a left menu bar.

The problem is, with this launchMode set, I see a horrible black flicker between activities on most devices. A Google search didn't turn up anything as to whether this is normal, or how to fix it.

I tried singleTask, but that doesn't do what I would like exactly, since if I go from task A - B - C, then back to A, task B is removed from the stack and its state must be reloaded again when I start that Activity.

Also, and this may be a lack of fully understanding singleInstance, but the back button no longer works for those Activities. What I would like to happen is that any singleInstance activity goes back to the home screen when the back button is pressed.

Any help on this would be greatly appreciated.

Thanks!

1 Answers1

0

Have you tried overriding your transition animation?

Here is some of my code that I use for that:

   public void goToNextScreen(View v) {


        if (savedCueCardActivity == null) {
            savedCueCardActivity = new Intent().setClass(this, CueCardActivity.class);
            startActivity(savedCueCardActivity);
            //       lastActivity.finish();
        } else {
            savedCueCardActivity.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            startActivity(savedCueCardActivity);
        }
        overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
    }
HalR
  • 11,411
  • 5
  • 48
  • 80
  • Is there a way to retain the state of an activity that is singleTask, without popping the whole task off the stack if I go back to another singleTask activity? –  Mar 16 '13 at 14:09
  • I prefer to not use the singleTask method and just keep a reference to my activity in my mainActivity. I just like the control. Then I just call startActivity on my saved activity. – HalR Mar 16 '13 at 18:18