Skip to main content
Known Participant
August 31, 2011
Answered

Prevent the device from turn off the screen

  • August 31, 2011
  • 1 reply
  • 587 views

Hi

Is there a way to avoid that the iPhone/iPad turn off the screen after a while without using the App?. I want to build an App (like a clock) that requires that the screen be always ON and Dimmed. Does anybody knows if this is possible in AS3?

(It must override the system configuration for turn-off the screen)

Thank you

This topic has been closed for replies.
Correct answer xs2bas

import flash.system.Capabilities;

if (Capabilities.cpuArchitecture == "ARM") {

     NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, f_StayAwake, false, 0, true);

}

private function f_StayAwake(event:Event):void {
     NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
}


1 reply

xs2basCorrect answer
Inspiring
August 31, 2011

import flash.system.Capabilities;

if (Capabilities.cpuArchitecture == "ARM") {

     NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, f_StayAwake, false, 0, true);

}

private function f_StayAwake(event:Event):void {
     NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
}


Known Participant
August 31, 2011

Thanks for your generosity!

Works Great!