How to turn screen on and off programmatically?

2 posts, 0 answers
  1. Anushika M
    Anushika M avatar
    2 posts
    Member since:
    Feb 2015

    Posted 12 Mar 2015 Link to this post

    i want to set screen time out within my app.Is there any way to adjust screen timeout or sleep mode on/off ?
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 17 Mar 2015 Link to this post

    Hi Anushika,

    I am not sure that I understand exactly your requirement. However, when it comes to controlling the screen dimming or screen lock in a hybrid Cordova application, there are a couple of plugins you can use:
    • Telerik Verified Insomnia plugin allows you to prevent the screen from dimming (and locking the device) while the user is not touching the screen.
    • PowerManagement plugin which offers access to the devices power-management functionality. It should be used for applications which keep running for a long time without any user interaction. You can import it in an AppBuilder project following these instructions and you can also have a look at this forum thread where you will find a sample project demonstrating the plugin's functionality.

    Further, the Cordova API exposes two events related to the app's state:
    • pause: the event fires when the native platform puts the application into the background, typically when the user switches to a different application.
    • resume: the event fires when the native platform pulls the application out from the background.

    Let me know if this information helps and if you have more questions.

    Regards,
    Tina Stancheva
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
Back to Top