Hi,

I would like to write an activity that after clicking on a button
turns off the screen and then turns it back on after 2 secs.
I tried using the following code in order to power off the screen:
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = 0/(float)255;
getWindow().setAttributes(lp);

But it would only take effect when then onClick function returned. I
tried running it into a handler but with no success.
I need to find a way to force the setting to get applied before the
function returns so that I can call the power on function 2 secs later
on the same onClick call.

I also found it very hard to wakeup the device afterwards.
While this code works if I power off the screen using the physical
button it doesn't seem to work when the phone is powered off using the
technique described previously.

PowerManager pm =
(PowerManager)this.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK|
PowerManager.ACQUIRE_CAUSES_WAKEUP |
PowerManager.ON_AFTER_RELEASE ,"Dev Tag");
try
{
    wl.acquire();
    wl.release();
}
catch (Exception e)
{
    Toast.makeText(this, e.getMessage(),20).show();
}

Thanks you in advance for your help!
Sincerely,
S.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to