How to Keep the Screen On

by BlackBerry Development Advisor on ‎04-21-2011 04:50 PM (4,236 Views)

Summary

 

This article applies to the following:

    BlackBerry® Tablet OS

Details

 

By default, the screen of a BlackBerry® PlayBook™ will turn off if there is no user activity within the backlight time-out period configured in the screen options of the BlackBerry PlayBook.  Adobe® AIR® applications can override this time-out value and keep the screen on indefinetly by changing the system idle mode to SystemIdleMode.KEEP_AWAKE.  The code sample below demonstrates how to toggle this value.

 

 

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
		       xmlns:s="library://ns.adobe.com/flex/spark" 
		       xmlns:mx="library://ns.adobe.com/flex/mx">

<fx:Script>
<![CDATA[
protected function checkBox_clickHandler(event:MouseEvent):void
{
if(CheckBox(event.target).selected) 
{
statusLabel.label = "The screen will remain on.";
NativeApplication.nativeApplication.systemIdleMode = 
SystemIdleMode.KEEP_AWAKE;
else 
{
statusLabel.label = "The screen will turn off.";
NativeApplication.nativeApplication.systemIdleMode = 
SystemIdleMode.NORMAL;
}
}
]]>
</fx:Script>
<mx:Form x="10" y="10">
<mx:FormItem label="Keep Screen On: ">
<s:CheckBox id="checkBox" click="checkBox_clickHandler(event)"/>
</mx:FormItem>
<mx:FormItem label="The screen will turn off." id="statusLabel">
</mx:FormItem>
</mx:Form>
</s:WindowedApplication>