Search code examples
delphimobilefiremonkeydelphi-xe8sleep-mode

How can I prevent apps from going into sleep mode in Delphi XE8


I have a multi device Firemonkey project in Delphi XE8 which I use to make iOS and Android apps. If I am running my apps on the devices they sometimes go to sleep if I didn't touch the screen but the app is still loading stuff.

So how can I stop the app from going into sleep mode for both Android and iOS?


Solution

  • There is currently no universal way to prevent a mobile FireMonkey application from going to sleep when user activity is too low.

    For iOS there is one proposed solution here: XE4 Firemonkey on iOS prevent sleep mode and for Android is another one: Delphi XE5 Android. How to use PowerManager.WakeLock?.

    They are using different API calls and methods, so it would be difficult to share the same code. You could wrap the functionality into a library and with some ifdef's perhaps invoke it the same way.