# I want to know how to turn off the cell phone when I press the back button. (at processing android)

**URL:** <https://discourse.processing.org/t/i-want-to-know-how-to-turn-off-the-cell-phone-when-i-press-the-back-button-at-processing-android/1041>\
**Category:** Processing for Android\
**Created:** [June 18, 2018, 2:42am UTC](https://discourse.processing.org/t/i-want-to-know-how-to-turn-off-the-cell-phone-when-i-press-the-back-button-at-processing-android/1041 "2018-06-18T02:42:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [June 18, 2018, 2:42am UTC](https://discourse.processing.org/t/i-want-to-know-how-to-turn-off-the-cell-phone-when-i-press-the-back-button-at-processing-android/1041/1 "2018-06-18T02:42:10Z")

</div>

I want to know how to turn off the cell phone when I press the back button. (at processing android)

For example, in JAVA (PC)

```auto
void keyPressed () {
   if (key == ESC) {
     key = 0; // Empêche d'utiliser la touche ESC
   }
}

```

The program does not turn off when you press the ESC button as follows.

Is there a way to make sure your smartphone does not turn off when you press Back? (at processing android)

---

<div class="post-metadata">

**Author:** ![calsign](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/calsign/32/30_2.png) [@calsign](https://discourse.processing.org/u/calsign)\
**Post date:** [June 18, 2018, 7:08am UTC](https://discourse.processing.org/t/i-want-to-know-how-to-turn-off-the-cell-phone-when-i-press-the-back-button-at-processing-android/1041/2 "2018-06-18T07:08:15Z")

</div>

On Android, you can override `onBackPressed()` to stop the sketch from quitting, but this stopped working when Android mode switched to using fragments because that method is in activity, not fragment. See [this issue](https://github.com/processing/processing-android/issues/414) on GitHub for more information. However, it seems that @Andres implemented a fix just 12 hours ago, so this feature should be available for the next release of Android mode.

---

<div class="post-metadata">

**Author:** ![Andres](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/andres/32/18007_2.png) [@Andres](https://discourse.processing.org/u/Andres)\
**Post date:** [June 18, 2018, 7:30pm UTC](https://discourse.processing.org/t/i-want-to-know-how-to-turn-off-the-cell-phone-when-i-press-the-back-button-at-processing-android/1041/3 "2018-06-18T19:30:06Z")

</div>

@GWAK as @calsign mentioned, the next version of the Android mode (4.0.2) will fix the handling of the back button. This version will be released soon, I will post here when is ready to download.

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [June 18, 2018, 8:33pm UTC](https://discourse.processing.org/t/i-want-to-know-how-to-turn-off-the-cell-phone-when-i-press-the-back-button-at-processing-android/1041/4 "2018-06-18T20:33:22Z")

</div>

Thanks~ very…

Nice reply!!

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [June 18, 2018, 8:33pm UTC](https://discourse.processing.org/t/i-want-to-know-how-to-turn-off-the-cell-phone-when-i-press-the-back-button-at-processing-android/1041/5 "2018-06-18T20:33:58Z")

</div>

Thanks~ very…

Nice reply!!

nice~!

---

<div class="post-metadata">

**Author:** ![Andres](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/andres/32/18007_2.png) [@Andres](https://discourse.processing.org/u/Andres)\
**Post date:** [June 19, 2018, 7:41pm UTC](https://discourse.processing.org/t/i-want-to-know-how-to-turn-off-the-cell-phone-when-i-press-the-back-button-at-processing-android/1041/6 "2018-06-19T19:41:06Z")

</div>

The new version of the mode (4.0.2) is ready! It should appear in the Contributions Manager soon, you can also download it manually from the [releases page](https://github.com/processing/processing-android/releases) on GitHub.
