Work with NewIntent for FLAG_ACTIVITY_NEW_TASK

I have an Activity running in singleTop mode and a C2DM receiver. With some kind of notification, I need to run this action, and I do it as follows:

Intent activity = new Intent(context, klass);
activity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(activity);

In action, if the background (for example, the Home button is pressed earlier), everything works fine. But when I just pressed the power button to turn off the screen, the current activity cannot be notified of some changes ( onNewIntentnever called).

How can I notify current notification activity?

+5
source share
2 answers

Skayred, , . , , , , ( , ).

wakelock C2DM.

PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK|PowerManager.ACQUIRE_CAUSES_WAKEUP,     TAG);
mWakeLock.acquire();

, mWakeLock.release() .

, , , Android. singleTask ( , , ). , , , onCreate():

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

, , . , . , wakelock.

+4

:

  • , .
  • , , C2DM, .
  • -
  • C2DM
  • onCreate , onDestroy
  • , , ,

.

+1

All Articles