Hi,
such information as this is probably out here - but here comes a small
guideline (perhaps more suited for a blog - but anyhow - here we go).

We have received a question or two on how to programmatically disable
the screen saver in android devices.

If you are playing a video the the preferred way is to use the
MediaPlayer.setScreenOnWhilePlaying() method.

If that doesn't have the wanted effect or in other cases there is a
Power Manager API that can be used. 
http://developer.android.com/reference/android/os/PowerManager.htmland
the wake lock mechanism.

This mechanism must be handled with great care. There are two things
that really must be kept in mind.

1. The partial wakelock lets the CPU run even when the screen is off -
thus it may drain the battery easily if you not pay strct attention to
closing it.

2. Also note that you should ALWAYS decide if the wakelock that is
used needs to be reference counted or not, the default in Android is
TRUE. The normal and preferred settings is FALSE!

Example:

PowerManager pm = (PowerManager)
getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(
 
PowerManager.SCREEN_BRIGHT_WAKE_LOCK
                                      |
PowerManager.ACQUIRE_CAUSES_WAKEUP,
                                      "My Tag indeed");



w1.setReferenceCounted(FALSE);
wl.acquire();
   ..screen will stay on during this section..
wl.release();


For further information check:

http://developer.sonyericsson.com/wportal/devworld/article/newsandevents-latestnews-androidpower?cc=gb&lc=en

and

http://developer.android.com/reference/android/os/PowerManager.html

Kind regards
  /Johan
Sony Ericsson Developer Support #SEDW

-- 
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