# How to keep the screen awake

**URL:** <https://discourse.processing.org/t/how-to-keep-the-screen-awake/1601>\
**Category:** Processing for Android\
**Created:** [July 8, 2018, 8:58pm UTC](https://discourse.processing.org/t/how-to-keep-the-screen-awake/1601 "2018-07-08T20:58:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![chanof](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@chanof](https://discourse.processing.org/u/chanof)\
**Post date:** [July 8, 2018, 8:58pm UTC](https://discourse.processing.org/t/how-to-keep-the-screen-awake/1601/1 "2018-07-08T20:58:44Z")

</div>

Hi! I would like to ask how I can keep the screen awake while I use my application inside Android, I found different solutions all out of dated.  
Thanks

---

<div class="post-metadata">

**Author:** ![DogeMastr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/dogemastr/32/689_2.png) [@DogeMastr](https://discourse.processing.org/u/DogeMastr)\
**Post date:** [July 8, 2018, 9:21pm UTC](https://discourse.processing.org/t/how-to-keep-the-screen-awake/1601/2 "2018-07-08T21:21:56Z")

</div>

A good start would be allowing the app to `wake_lock` the screen,  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/1X/57aa48d58e6a63b9f0079466c0c45acf9ed513d7.png)  
you can find that menu in:  
Android \> sketch permissions  
I haven’t dont much testing with permissions (im fairly new to android processing) but maybe just having that box ticked keeps the phone awake

* * *

Doge

---

<div class="post-metadata">

**Author:** ![chanof](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@chanof](https://discourse.processing.org/u/chanof)\
**Post date:** [July 8, 2018, 10:11pm UTC](https://discourse.processing.org/t/how-to-keep-the-screen-awake/1601/3 "2018-07-08T22:11:07Z")

</div>

Useful start point @DogeMastr  
this permission seems to be used to keep the cpu on while the screen is off, however useful!  
Thanks

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [July 8, 2018, 10:42pm UTC](https://discourse.processing.org/t/how-to-keep-the-screen-awake/1601/4 "2018-07-08T22:42:23Z")

</div>

Check this: [https://forum.processing.org/two/discussion/comment/51740/#Comment\_51740](https://forum.processing.org/two/discussion/comment/51740/#Comment_51740)

I believe you need to include:

```auto
 import android.os.Bundle;
 import android.view.WindowManager;
 import android.view.View;

```

Kf

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [July 9, 2018, 7:14am UTC](https://discourse.processing.org/t/how-to-keep-the-screen-awake/1601/5 "2018-07-09T07:14:46Z")

</div>

@chanof===

permissions is needed of course, but you have to ask by code:

`getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);`

creating a thread for that.

importing what is required (WindowManager, Activity…); dont forget to unlock when onPause().
