Keep Screen On

896
10
Jump to solution
12-03-2018 12:01 PM
BrianLomas
Occasional Contributor III

Within appstudio, is there a way to keep the screen from going to standby and locking while your app is running? I'm using appstudio desktop version 3.0.53 and configuring the quick capture template.

Thanks.

Tags (1)
1 Solution

Accepted Solutions
TinaJin
Esri Regular Contributor

Hi Brian,

The Platform.stayAwake = true should set inside a signal handler, for example, in the code sample below, stayAwake is inside an onClicked signal.  If you wish to keep the screen on when opening the app, you can put stayAwake inside Component.onCompleted.

Note:  Best practice for using stay awake is to set this property to false before the app is minimized or closed. 

import ArcGIS.AppFramework.Platform 1.0

    ColumnLayout {
        anchors.fill: parent

        Button {
            text: "Enable Stay Awake"
            onClicked: {
                Platform.stayAwake = true;
            }
        }
        Button {
            text: "Disable Stay Awake"
            onClicked: {
                Platform.stayAwake = false;
            }
        }
     }

View solution in original post

10 Replies
TinaJin
Esri Regular Contributor

Hi Brian,

The upcoming AppStudio 3.2 release (December 2018) will roll out a new Platform plugin, which includes a stayAwake property that can prevent your device from going to sleep.  Please keep an eye on the AppStudio 3.2 release blog post. I hope it helps.  

Thanks,

Tina 

BrianLomas
Occasional Contributor III

That would be great! Thx!

0 Kudos
BrianLomas
Occasional Contributor III

I am now working with Appstudio 3.2. I am using the QuickCapture template as well. I placed "property bool stayAwake: true" in several places but I can't seem to get it to work. I would like the screen to stay on while the app is open or while the data capture page is open. Can you help me understand how to use this feature? I apologize if this seems like a basic question. Thanks for your time.

0 Kudos
TinaJin
Esri Regular Contributor

Hi Brian,

The Platform.stayAwake = true should set inside a signal handler, for example, in the code sample below, stayAwake is inside an onClicked signal.  If you wish to keep the screen on when opening the app, you can put stayAwake inside Component.onCompleted.

Note:  Best practice for using stay awake is to set this property to false before the app is minimized or closed. 

import ArcGIS.AppFramework.Platform 1.0

    ColumnLayout {
        anchors.fill: parent

        Button {
            text: "Enable Stay Awake"
            onClicked: {
                Platform.stayAwake = true;
            }
        }
        Button {
            text: "Disable Stay Awake"
            onClicked: {
                Platform.stayAwake = false;
            }
        }
     }
BrianLomas
Occasional Contributor III

Thanks Tina, this is very helpful and a great new feature. I really appreciate the quick and detailed response. Thanks again.

0 Kudos
BrianLomas
Occasional Contributor III

This function appears to only work while using in the appstudio player. When I built an apk file and deployed the app through the playstore, the stayawake function did not work. 

0 Kudos
TinaJin
Esri Regular Contributor

Hi Brian, 

This is odd because I have tested stay-awake function in a stand-alone app on Android devices and it works well. 

  • Have you tried to install the app directly on your Android device, does it work? 
  • What's your device model and Android version?
  • Do you have the latest AppStudio Desktop installed? 
  • Notice that stay awake will work when your app is running on foreground. If you minimize or close the app, stay awake will not work. 

Tina 

0 Kudos
BrianLomas
Occasional Contributor III

Hey Tina,

  • Have you tried to install the app directly on your Android device, does it work? The stayawake function did not work when the apk was installed directly on the phone.
  • What's your device model and Android version? Samsung Galaxy S7; Android version 8
  • Do you have the latest AppStudio Desktop installed?  version is 3.2.79
  • Notice that stay awake will work when your app is running on foreground. If you minimize or close the app, stay awake will not work. Stayawake performs perfectly while in the appstudio player but not from the apk for some reason.
0 Kudos
BrianLomas
Occasional Contributor III

I was able to get stayAwake to work with an app from the google play store. It did not work when adding the property in the Component.onCompleted section of the code of an app in the play store but it did within the appstudio player. So, I added stayAwake to an onselected function within the code and it works. I'm not sure if this is a coding issue or just an issue of my understanding of the quickcapture application. Thanks Tina Jin‌ for all the help on this.

0 Kudos