How to keep the screen awake


#1

Hi! I would like to ask how I can keep the screen awake while I use my application inside Android, I found different solutions all out of dated.
Thanks


#2

A good start would be allowing the app to wake_lock the screen,


you can find that menu in:
Android > sketch permissions
I haven’t dont much testing with permissions (im fairly new to android processing) but maybe just having that box ticked keeps the phone awake


Doge


#3

Useful start point @DogeMastr
this permission seems to be used to keep the cpu on while the screen is off, however useful!
Thanks


#4

Check this: https://forum.processing.org/two/discussion/comment/51740/#Comment_51740

I believe you need to include:

 import android.os.Bundle;
 import android.view.WindowManager;
 import android.view.View;

Kf


#5

@chanof===

permissions is needed of course, but you have to ask by code:

getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

creating a thread for that.

importing what is required (WindowManager, Activity…); dont forget to unlock when onPause().