How do I force the screen not to go black/sleep (timeout)

Get help using Construct 2

Post » Sun Jan 22, 2017 4:16 pm

When the screen hasn't been touched for some time it goes black/into sleep mode. The time it takes depends on the settings in the phone. Called Screen timeout (I guess, my phone is not in english though)

Can that be controlled by an app? the timeout period is a timeframe from last time you touched the screen.

But I am playing with a game that you controll with the gyro. you do not have to tap the screen. But then the phone always go black after 30sec since you do not touch the screen... Possible to force it to be awake while in a certain app?
B
15
S
4
Posts: 83
Reputation: 1,146

Post » Tue Jan 24, 2017 10:12 am

@Kyatric or @Ashley , is this possible in Construct2 right now. To prohibit the screen from sleep mode? (Maybe I just missed the functionality)

Otherwise, possible to implement the function into a standard action? Or is this to be set in the XDK somehow?

From Android developer I know there is a flag called FLAG_KEEP_SCREEN_ON

Code: Select all
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
to disable the screen timeout and

getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
to re-enable it.



Explained in detail here:
https://developer.android.com/training/ ... elock.html
B
15
S
4
Posts: 83
Reputation: 1,146

Post » Tue Jan 24, 2017 11:27 am

Already answered in this 2 years old topic : https://www.scirra.com/forum/keeping-mobile-app-awake-prevent-screenlock_t163137
You have to add a Cordova plugin to the Intel XDK project.
Latest/working plugin link is in the third page. Nevertheless, read the whole topic, it can be useful.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
284
S
109
G
91
Posts: 7,319
Reputation: 87,487

Post » Tue Jan 24, 2017 12:09 pm

Sorry, didn't find that topic before.

Thank you!
B
15
S
4
Posts: 83
Reputation: 1,146


Return to How do I....?

Who is online

Users browsing this forum: plinkie and 1 guest