[Android] How to prevent 'BACK button'?

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();

void draw() {


public void onBackPressed() {

toast.makeText(act.getApplicationContext(), “There is no back action”, Toast.LENGTH_LONG).show();

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

Just leave the onBackPressed function empty.

1 Like


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.

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

1 Like

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.