Smartphone display always on

I’m completing a game that performs activities automatically without touching the mobile screen.

This means that the mobile screen turns off if it is not touched.

How can I keep the screen always on during the game?

:sweat_smile: I think the question is difficult to solve

1 Like

What platform? If Android there is some nice documentation.
Keep the device awake | Android Developers
I just tested the first method listed and it works fine. I set my device to sleep after 15 seconds, but with my game on it is staying open.
Let me know if you need more help.

Might require a manual build.

1 Like

yes, android system, thanks. Now I read that documentation. :smiley:

1 Like

If you don’t mind manually building your project. But I know a lot of people don’t want to do that so I hate to even waste time suggesting it. But if you don’t mind building manually and get stuck let me know. I will throw up a screen shot.

1 Like

I’m not that good at building by hand. If you please take a screenshot it will help me a lot. A thousand thanks :pray: :blush:

1 Like

Ok I will when I get home. Do you have your whole environment set up for building manually or do you just do it in Android Studio?

1 Like

I use android studio

1 Like

Ok export your project to an empty folder of your choice. Open cmd in the folder and run: cordova platform add android@11. Open the new Platform folder that was created and locate the folder that says Android. Do not open but keep it there for dragging into Android Studio.

Open Android Studio. Close the existing project it opens, if any. From the main screen select Open and drag the Android folder into the pane. Make sure the pane shows the path to the folder open up (Android Studio can sometimes take a second to find it if you had Android Studio open already and just created a new folder. If it doesn’t open the path, click cancel, select Open from the main screen and try again.) Open the project.

After the project is synced and w/e in Android Studio, make sure your project files are displayed in Android View because it will make it easier to find the file you need. Open App/Java/Com/ and find the folder with the name you gave as your package name. In that you will see a file called MainActivity. Double click or select it and Enter to open it.

Copy this line from the first example in the link in previous post:


and paste it under this line in your MainActivity:


Hit enter. It should automatically import what you need. Look at the top of the file that says: import… and expand it and make sure the line I have highlighted is in there. If not and you are seeing red error underlines, then click your cursor in the word WindowManager in the line you pasted. Hit Alt + Enter. When the selection box pops up, select Import. Or just type the import line I have highlighted in there yourself.

Build project with Android Studio.
If I left something out or you run into any kinks just holler.

1 Like

thanks Lucky-j, :blush: now i will try to implement with your function.

Hello, I had already solved the problem in GDevelop with a self-made extension. I had used it for my timer app:

look at the post:

Greetings Markus


There’s an interesting article with another alternative here too:

1 Like

It works :smiley: Thanks everyone. I tested the easiest alternate for me (Markus’s) and it works.

@Mr_Nick666 I will also read this article later.

thanks everyone for the help. For me this discussion can be closed.