2

I want to create an alert application. The alert is received using GCM (GoogleCloudMessaging). Now I want to show the alert message on the screen without any actions by the user. Therefore I need to wake up the device and unlock the screen.

In the forum I found this answer (and some similar) describing how I can achieve this behaviour: android-wake-up-and-unlock-device

Reading the documentation, using WakeLocks seems to be deprecated: i.e. full_wake_lock

FULL_WAKE_LOCK Added in API level 1

int FULL_WAKE_LOCK

This constant was deprecated in API level 17. Most applications should use FLAG_KEEP_SCREEN_ON instead of this type of wake lock, as it will be correctly managed by the platform as the user moves between applications and doesn't require a special permission.

In the documentation an alternative is shown using the WindowManager. With help of the flags

WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD

I should be able to bring my alert message to the front without asking for the keyguard secure pattern.

My question now is: When I want to use these flags, do I also need a wakeLock to wake up my device or is this done implicit by the window manager?

Community
  • 1
  • 1
paul_schaefer
  • 397
  • 4
  • 16

0 Answers0