# \[Android\] How to prevent 'BACK button'?

**URL:** https://discourse.processing.org/t/android-how-to-prevent-back-button/24133
**Category:** Processing for Android
**Created:** [September 26, 2020, 7:01am UTC](https://discourse.processing.org/t/android-how-to-prevent-back-button/24133 "2020-09-26T07:01:10Z")
**Posts on this page:** 5
**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: [September 26, 2020, 7:01am UTC](https://discourse.processing.org/t/android-how-to-prevent-back-button/24133/1 "2020-09-26T07:01:11Z")

</div>

Tool : Processing3.5.3 / Android mode

- Android SDK 10
- Android mode 3.0.1

How to prevent ‘BACK button’ ?

> import android.app.Activity;  
> import android.content.DialogInterface;  
> import android.app.Activity;  
> import android.app.AlertDialog;  
> import android.text.Editable;  
> import android.widget.EditText;  
> import android.widget.Toast;  
> import android.app.Activity;  
> import android.content.Intent;  
> import android.os.Bundle;
> 
> import android.os.Bundle;  
> import android.util.Log;  
> import android.view.KeyEvent;
> 
> Activity act;  
> private Toast toast;  
> private Toast toast2;
> 
> void setup() {
> 
> fullScreen(); background(100);  
> act = this.getActivity();  
> println(" SETUP!");
> 
> }  
> void keyPressed () {  
> if (key == CODED) {  
> if (keyCode == KeyEvent.KEYCODE\_BACK) {  
> toast2.makeText(act.getApplicationContext(), “There is no back action”, Toast.LENGTH\_LONG).show();  
> return;  
> }}}
> 
> void draw() {
> 
> }
> 
> public void onBackPressed() {
> 
> toast.makeText(act.getApplicationContext(), “There is no back action”, Toast.LENGTH\_LONG).show();  
> return;  
> }

Is there any way to block the’back’ button?

---

<div class="post-metadata">

### Author: ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)
#### Post date: [September 26, 2020, 12:46pm UTC](https://discourse.processing.org/t/android-how-to-prevent-back-button/24133/2 "2020-09-26T12:46:58Z")

</div>

Hi @GWAK  
Just leave the onBackPressed function empty.

---

<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: [September 26, 2020, 1:07pm UTC](https://discourse.processing.org/t/android-how-to-prevent-back-button/24133/3 "2020-09-26T13:07:00Z")

</div>

@noel

Thanks for commenting.

Android mode 3.0.1

If you simply empty it, it will just quit. I can’t block the back button. Immediately the application ends.

> <https://github.com/processing/processing-android/issues/414>
>
> I can't seem to find a way to stop a Processing app from closing on clicking the back button - I'm...

---

<div class="post-metadata">

### Author: ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)
#### Post date: [September 26, 2020, 5:21pm UTC](https://discourse.processing.org/t/android-how-to-prevent-back-button/24133/4 "2020-09-26T17:21:06Z")

</div>

Do you really need Android PC?  
On APDE it works fine on KitKat, Lollipop, as on Android 10 as well.

---

<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: [September 26, 2020, 11:29pm UTC](https://discourse.processing.org/t/android-how-to-prevent-back-button/24133/5 "2020-09-26T23:29:24Z")

</div>

> version : Android mode 3.0.1 → not action  
> version : Android mode 4.1 → very well

It seems to be a problem with the processing inner core.  
However, there is a problem that the text’Android mode 4.1’ is broken.  
It seems that this part has not been solved in’processing’.  
So, I use’Android mode 3.0.1’ to make it easier.

> [@\[Android\] Regarding the Android mode, has the text breakage been resolved?](https://discourse.processing.org/t/android-regarding-the-android-mode-has-the-text-breakage-been-resolved/24139):
>
> Regarding the Android mode, has the text breakage been resolved? Please refer to the image. Korean Japanese English If you experiment through All texts are broken except in English. Did you come up with a solution?
