Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question How do I prevent screen locking on android? Screen.sleepTimeout does not work

Discussion in 'Android' started by Quantumstorey, Sep 15, 2022.

  1. Quantumstorey

    Quantumstorey

    Joined:
    Jun 1, 2017
    Posts:
    9
    Is there a way to prevent screen locking on Android?

    I have a mobile VR app in the Play Store where the screen locks after three minutes. This requires the user to remove their phone from the headset to unlock the app.

    I'm calling: Screen.sleepTimeout = SleepTimeout.NeverSleep; In Awake() in every scene. I've also tried calling it every frame in Update(). Nothing prevents screen locking.

    Is there a solid way to prevent screen locking on Android? The device is ignoring our request to stay alive without touch input.

    Unity 2021.2.13f
    Target API Level: Android 11
    Min API level: Android 9
     
  2. Quantumstorey

    Quantumstorey

    Joined:
    Jun 1, 2017
    Posts:
    9
    A little more info. This was tested on a Samsung Galaxy s21 and s22