This is a migrated thread and some comments may be shown as answers.

How to turn screen on and off programmatically?

1 Answer 153 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Anushika M
Top achievements
Rank 1
Anushika M asked on 12 Mar 2015, 10:41 AM
i want to set screen time out within my app.Is there any way to adjust screen timeout or sleep mode on/off ?

1 Answer, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 17 Mar 2015, 08:54 AM
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.

 
Tags
General Discussion
Asked by
Anushika M
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question
or