Keeping the Screen Awake (Until Pressing the HOLD Button)

If you are making some applications, like game, navigation, or even an eBook reader, that needs to be prevented from dimming; there are 2 things to be implemented in 'app_pause' and 'app_resume'.

 

In 'app_resume' function

This function will be called not only on backing from the pause state, but also on the start of the application.
Below is the best place to add the API for the screen lock

static void
app_resume(void *data)
{
    /* Take necessary actions when application becomes visible. */

	appdata_s *ad = data;

	device_power_request_lock(POWER_LOCK_DISPLAY, 0);
}

In 'app_pause' function

This function will be called when the user presses HOLD button.
The unlock screen API must be called here, if not, the screen will wake up instantly even right after the user presses HOLD button.

static void
app_pause(void *data)
{
    /* Take necessary actions when application becomes invisible. */
    appdata_s *ad = data;

    device_power_release_lock(POWER_LOCK_DISPLAY);

}

 

Last thing, don't forget to add #include <device/power.h> on the top of your code.

For more detailed information, please check the help page:
Tizen Mobile Native App Programming > API Reference > Native API Reference > System > Device > Power

List
SDK Version Since: 
2.3.0