Array

Overriding a Dimmed Screen

Must Read

Admin
Admin
Just post!

After your application is idle for a while, the OS makes the device screen go into dimming mode and sets your device to auto-lock if your settings request it. Note that this is different from AIR on the desktop. On the desktop, playing a video at full screen automatically blocks screensavers and power-saving modes. It does not happen automatically on Android.

If you wish to override this behavior during a certain activity, you need to set the following permissions:

<uses-permission android:name=”android.permission.WAKE_LOCK” />
<uses-permission android:name=”android.permission.DISABLE_KEYGUARD” />

For convenience, place this code in your document class or where you first set up your application settings. Import the needed classes:

import flash.desktop.NativeApplication;
import flash.desktop.SystemIdleMode;

Tell the native application to stay awake:

NativeApplication.nativeApplication.systemIdleMode
= SystemIdleMode.KEEP_AWAKE;

To set the native application to normal behavior again, use this code:

NativeApplication.nativeApplication.systemIdleMode
= SystemIdleMode.NORMAL;

Keep in mind that blocking the idle behavior has a negative impact on battery life. Test it and use it with caution.

 

- Advertisement -

Latest News

STOOF International presents armoured SUV Trojan with certified maximum protection

The "Trojan", based on the Toyota LC 300, in resistance class VR9, from STOOF International, represents an absolute novelty...
- Advertisement -

More Articles Like This

- Advertisement -