0

From the Android launcher source code,

if ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) !=
        Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) {
    //reset homescreen to default page
}

The launcher resets the homescreen to default page if the startActivity intent does not have the flag FLAG_ACTIVITY_BROUGHT_TO_FRONT.

The flag is only not set if there is already an instance of the activity being started at the top of the stack.

Is there a way to trick the launcher into thinking it's already running in the top of the stack (causing it to reset the homescreen pages) when it is launched from another app? (not from home key press).

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
kevdliu
  • 1,709
  • 4
  • 29
  • 46
  • 1
    Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT is only set by Android when it brings an activity to the front itself. Setting it yourself does nothing – Zar E Ahmer Dec 28 '16 at 06:07

1 Answers1

1

Follow my understanding about your question. I think FLAG_ACTIVITY_NEW_TASK flag can help you. The document say:

When using this flag, if a task is already running for the activity you are now starting, then a new activity will not be started; instead, the current task will simply be brought to the front of the screen with the state it was last in

And If there is already an instance of the activity are running. Method :

protected void onNewIntent(Intent intent)

will be called. So, you can reset your home screen from this method whenever there are a new intent come.

Hope it help.

gZerone
  • 673
  • 12
  • 28