문제

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).

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top