Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable screen timeout on NativeActivity

Tags:

android

I am developing app on NativeActivity(only C/C++).
I want to disable screen timeout.

Do you know how to do it?

like image 849
user1602722 Avatar asked Dec 12 '12 09:12

user1602722


People also ask

Can I turn off screen Timeout?

Open Settings. Tap Display. Tap Sleep or Screen timeout. Select how long you want your Android smartphone or tablet screen to stay on before turning off due to inactivity.

How to Set screen Timeout to never android?

All you need to do is click on the settings menu from the notification panel or the app drawer and go to the settings icon. Now click on the Display icon. Click on Screen Timeout and click on the Never option. After Clicking on Screen timeout your phone screen will stop turning off.


1 Answers

In case the OP is still looking for an answer or for anyone like me who finds topic this while searching, here's how you do it:

#include <android/window.h>

[...]

// place this in your init function once you have a valid window
ANativeActivity_setWindowFlags(pYourAppStruct->activity, AWINDOW_FLAG_KEEP_SCREEN_ON, 0);
like image 170
Rej Avatar answered Oct 05 '22 19:10

Rej