OnNewIntent () does not work until the phone wakes up

I found an interesting behavior and I don’t know why and how to get around it. Activity is a singlet activity, which means that onNewIntent () refers to the activity, while the activity is on the top of the stack. This works fine and well while the phone screen is on. However, when the screen is off, a new intention will not be received until the phone wakes up, and onNewIntent () is called at that moment. If the activity is not at the top of the stack and the phone is sleeping, then the action is launched and the onCreate () method is called.

Action declared as:

<activity android:name=".MyActivity" 
          android:launchMode="singleTask" 
          android:alwaysRetainTaskState="true" >

The activity also starts with the flag FLAG_ACTIVITY_NEW_TASK. The target is launched from the broadcast receiver. If the phone is asleep and the broadcast is intended, activity wakes the phone with these flags:

    getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); 
    getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);

However, activity is not created until the phone wakes up when it is at the top of the stack. Now I am perplexed and do not know where to start. Also my activity uses onSaveInstanceState (). This activity is fragmented activity and contains one fragment.

Any help would be greatly appreciated!

+3
source share
1 answer

However, activity is not created until the phone wakes up when it is at the top of the stack.

, . - .

http://developer.android.com/reference/android/os/PowerManager.WakeLock.html

, , , - . , onHandleIntent(),, . , .

, , , . , , , ... . .

, . , onHandleIntent() , . - :

receiver: acquire partial lock
activity: acquire screen lock
activity: release partial lock

, , ... , - .

+2

All Articles