Search code examples
androidandroid-activityscreen

How can I wake an android device up and skip the screenlock


As title, is it possible for me to wake my phone up and skip the screenlock? I want to write an app based on the alarm clock, when it's time, the app should do detect something in the background even when the phone is sleeping. When something is detected, the phone should automatically wake up, skip the screenlock, and show a picture(start a new activity ). Can anybody give me some suggestions or examples on these? Thanks a lot!


Solution

  • The activity you're starting needs one or both of the following layout parameters.

    Use FLAG_SHOW_WHEN_LOCKED so that the activity appears above the screenlock.

    Use FLAG_DISMISS_KEYGUARD to automatically dismiss the keyguard.

    More details at http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html.