How to prevent screen from dimming/turning off

How to prevent screen from dimming/turning off for both iOS and Android ?

I found this on stack overflow but how to use it in cocos2dx project’s Android manifestxml ? But I need solution for both iOS and Android.

I didn’t hear that it’s somehow built-in in cocos2d-x, however it’s not a problem.

simply add:

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

in cocos2d-x main activity class.

for iOS:

Add

UIApplication.shared.isIdleTimerDisabled = true

in AppDelegate class.

2 Likes