When the button is pressed the app crash ( or doesn't work)

edited March 9 in Android Mode

This is an app for an cat's automated food distributor, I need to create the menu and the profile for the cat, but it doesn't work.

// --- inclusion des librairies utilisées ---
import controlP5.*;
ControlP5 menu;
ControlP5 config;

// --- déclaration objets ---
//PImage fond;
// --- déclaration variables globales ---

void settings() {
  fullScreen();
}
/********************* Fonction SETUP **********************/
// fonction d'initialisation exécutée 1 fois au démarrage
/***********************************************************/
void setup()
{
  /**fond = loadImage ("KittyBoxfond.png");
   fond.resize(width, height);
   fond.loadPixels();
   background(fond);*/

  background(255, 0, 152);

  // ---- initialisation paramètres graphiques utilisés ---
  menu = new ControlP5(this);
  config = new ControlP5(this);  

  // --- initialisation des objets et fonctionnalités utilisées ---

  //création boutons pour le menu
  menu.addButton("Configuation")
    .setValue(0)
    .setPosition(20, 300)
    .setSize(755, 200)
    ;

  menu.addButton("Connexion_Bluetooth")
    .setValue(1)
    .setPosition(20, 550)
    .setSize(755, 200)
    ;

  //création boutons pour la configuration 
  config.addButton("Envoi des infos")
    .setValue(2)
    .setPosition(20, 425)
    .setSize(755, 100)
    ;

  config.addButton("Effacer")
    .setValue(3)
    .setPosition(20, 500)
    .setSize(275, 100)
    ;

  config.addButton("Retour")
    .setValue(4)
    .setPosition(200, 580)
    .setSize(100, 40)
    ;

  config.addTextlabel("label")
    .setText("Nom du chat:")
    .setPosition(20, 200);

  config.addTextlabel("label")
    .setText("Durée du voyage:")
    .setPosition(20, 250);

  config.addTextlabel("label")
    .setText("Numéro du badge:")
    .setPosition(20, 300);

  config.addTextlabel("label")
    .setText("Numéro de téléphone:")
    .setPosition(20, 350);

  config.addTextlabel("label")
    .setText("Nombre de distribution par jour:")
    .setPosition(20, 400);

  config.addTextlabel("label")
    .setText("Quantité de nourriture à distribuer:")
    .setPosition(20, 450);

  config.addTextlabel("label")
    .setText("Heure de distribution:")
    .setPosition(20, 500);


  config.hide();
}

/********************** Fonction DRAW **********************/
//             fonction exécutée en boucle
/***********************************************************/
void draw ()
{
}

/******************** Autres Fonctions *********************/
/***********************************************************/
public void Configuation(int theValue) {
  println("bouton config " +theValue);
  menu.hide();
  config.show();
}

public void Retour(int theValue) {
  println("bouton retour " +theValue);
  menu.show();
  config.hide();
}

public void Connexion_Bluetooth(int theValue) {
  println("bouton Connexion Bluetooth " +theValue);
}

This is the error I get:

debug:
FATAL EXCEPTION: Animation Thread
java.lang.NullPointerException
    at processing.core.PGraphicsAndroid2D.backgroundImpl(Unknown Source)
    at processing.core.PGraphics.backgroundFromCalc(Unknown Source)
FATAL EXCEPTION: Animation Thread
    at processing.core.PGraphics.background(Unknown Source)
    at processing.core.PGraphics.defaultSettings(Unknown Source)
java.lang.NullPointerException
    at processing.core.PGraphics.checkSettings(Unknown Source)
    at processing.core.PGraphicsAndroid2D.backgroundImpl(Unknown Source)
    at processing.core.PGraphicsAndroid2D.beginDraw(Unknown Source)
    at processing.core.PGraphics.backgroundFromCalc(Unknown Source)
    at processing.core.PGraphics.background(Unknown Source)
    at processing.core.PGraphics.defaultSettings(Unknown Source)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.core.PGraphics.checkSettings(Unknown Source)
    at processing.core.PGraphicsAndroid2D.beginDraw(Unknown Source)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source)
    at processing.core.PApplet.run(Unknown Source)
    at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source)
    at java.lang.Thread.run(Thread.java:838)
    at processing.core.PApplet.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:838)
Tagged:

Answers

Sign In or Register to comment.