-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

asma
  • 71
  • 2
  • 11

1 Answers1

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);
Rotemmiz
  • 7,933
  • 3
  • 36
  • 36
  • @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 '12 at 12:34