I want to disable auto-lock when my app is open. How can I do that?
For iOS, you need to override the DidFinishLaunchingWithOptions method in your Appdelegate class:
public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions)
{
UIApplication.SharedApplication.IdleTimerDisabled = true;
....
}
For Android, you need to do the following things in your MainActivity for it:
you have to declare this uses-permission on AndroidManifest:
Create a global field for WakeLock using static Android.OS.PowerManager;;
private WakeLock wakeLock;
And in your OnResume:
PowerManager powerManager = (PowerManager)this.GetSystemService(Context.PowerService);
WakeLock wakeLock = powerManager.NewWakeLock(WakeLockFlags.Full, "My Lock");
wakeLock.Acquire();
Just remember to release this lock when your application is paused or destroyed by doing this:
wakeLock.Release();
Usually, it's suggested to call the acquire method inside the onResume() of your activity and the release method in onPause(). This way we guarantee that our application still performs well in the case of being paused or resumed.
Goodluck revert in case of queries