Jump to content
erva

Preventing iOS to lock screen

Recommended Posts

Is there way to prevent iOS automatically lock screen?

 

I'am my self using one fitness app and it stays visible when doing workout, so it should be possible.

Share this post


Link to post

In Fmx this would look somewhat like this:

function  DoLocked(const ALock : Boolean) : Boolean;
var
    UIApp : UIApplication;
begin
    UIApp := TUIApplication.Wrap(TUIApplication.OCClass.sharedApplication);

    if ALock  then
    begin
        UIApp.setIdleTimerDisabled(True);    // aquire  wakelock
        Result := True;
    end
    else
    begin
        UIApp.setIdleTimerDisabled(False);  // release wakelock
        Result := False;
    end;
end;

I put some more functionality around that basic one, to make it workable on all platforms, and to avoid double-enabling,
but I removed that from the code above.

Edited by Rollo62
  • Like 2
  • Thanks 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×