Avoid screen lock on Android and VR

1

I am programming a VR apk with Unity but the following problem arises.

Being a VR application, I do not have any contact with the touch screen of my mobile phone, so after 10 seconds the screen dims and 5 seconds later it crashes.

I would like to know what solution I can give to this without having to deactivate the screen lock from the mobile.

    
asked by Marchena14 26.07.2017 в 12:53
source

2 answers

1

You have to use sleepTimeout :

Screen.sleepTimeout = SleepTimeout.NeverSleep;

To avoid blocking the mobile.

If you have any problems, add this to the manifiest for permissions:

 <uses-permission android:name="android.permission.WAKE_LOCK" />
    
answered by 26.07.2017 / 12:58
source
1

Try to keep the screen always on with this method

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

Within your activity, call it in some method that requires you to apply this, and once it is finished, you can remove it with this method.

getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_‌​SCREEN_ON)

I hope it works for you.

    
answered by 26.07.2017 в 16:10