-1

Anybody know that how to wake a phone with any action but without pressing power button or any hard-key and in android programmatically..

Thanks in advance

1

1 Answer 1

4

Yo can create a wakelock using these two flags

PowerManager.SCREEN_BRIGHT_WAKE_LOCK|PowerManager.ACQUIRE_CAUSES_WAKEUP

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK|PowerManager.ACQUIRE_CAUSES_WAKEUP, "wake");
wakeLock .acquire();

This will turn the device to the lockscreen.

Use these flags to get past the lockscreen:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
1
  • @Rotemimz: I am doing application to unlock screen using accelerometer sensor. So screen will unlock by shaking. but problem is user should first press anykey then shake then screen will lock. I want to avoid pressing key. how to avoid it..
    – asma
    Feb 19, 2012 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.