mobile phone getting lock if we not touched screen.

I developed an android game , when playing game lights getting of in some seconds and mobile phone getting lock if we not touched screen.

My client does not need phone getting lock.

How to avoid this using C# code.And how to run android game in background.

You can keep the screen locking using the methods specified at Keeping the Device Awake

One quick way is by using the Application’s layout XML file where you need to set your android:keepScreenOn attribute to be true in this file. The code snippet from that page for this is:

<RelativeLayout xmlns:android=""

Also to run an application in background on Android you need to run is as a service. This service will be written outside the actual game code. Search for building Android services to get an idea of how it can be done. Then you can call this service from your game via a Plugin. You can use OnApplicationPause to get notified when the application is paused. You can also check the activity cycle for Android to understand under which conditions your app will be sent to the background and how to handle it. Then try to find similar calls from Unity.

@LijuDeveloper, Unity is using a WakeLock to keep the phone from locking. If this does not work for you - which device and Android version are you using?

I got Solution

    // Disable screen dimming

Screen.sleepTimeout = SleepTimeout.NeverSleep;