Quantcast
Channel: Android Mode - Processing 2.x and 3.x Forum
Viewing all 941 articles
Browse latest View live

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

$
0
0

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)

How can i add admob to my app ?

Android-serial

$
0
0

Im working with a contributed library and i followed all the steps mentioned in the link

https://github.com/inventit/processing-android-serial

I'm getting a build error (attached image): Build-error

I have no clue what error it could be. Is it the version of android or something else?

Any help would be appriciated! -Thanks Goutham

Accessing SD Cards for storage

$
0
0

This could go in the code in code sharing but is Android only so might be better here?

Basically I have been trying to find ways of making use of my physical SD card, as the default seems to always be the internal emulated SD (apparently for android historical reasons). This seems to be a common problem for us amateur developers if the number of questions about it at Stack Overflow is anything to go by! Anyhow... this is my approach which seems to work, so thought I'd share. Dependent on API level it gets the file path(s) for your sd cards and converts them to strings. The result is actually to a file area specific to your app (for private data) and here I simply text() these to the display in draw(), but it is now easy to extract the first part of the string(s) which is the top level path to the sd cards themselves. On my LG phone these are /storage/emulated/0 and storage/external_SD/ ... on other phones these will be different and on oldish phone will probably be /mnt/...

Anyway, hope it may be of some use to some of you.

Mark

import android.os.Environment;
import android.os.Build ;
import android.app.Activity;
import android.content.Context;

Activity activity ;
Context context ;

File SDcard ; //emulated .... e.g. /storage/emulated/0
File[] SDcards ;
String sdPath0, sdPath1 ; // for emulated & external SD possibilities

void setup() {
  fullScreen();
  Activity activity = this.getActivity();
  Context context = activity.getApplicationContext();

  // get files paths for SD cards(s) and convert to Strings
  if (Build.VERSION.SDK_INT >= 19) {
    //from API19 (4.4 KitKat) get array of filepaths for all connected SD cards (and other media?)
    //1st path returned is emulated primary SD, 2nd path is real external SD, etc.
    SDcards = context.getExternalFilesDirs(null);
    sdPath0 = SDcards[0].toString() ;
    sdPath1 = SDcards[1].toString() ;
  } else if (Build.VERSION.SDK_INT >= 8) {
    //from API8 you can only get the file path of the primary SD card
    //(could be emulated or real)
    SDcard = context.getExternalFilesDir(null);
    sdPath0 = SDcard.toString() ;
  }

  fill(0) ;
}

void draw() {
  background(175);
  if (Build.VERSION.SDK_INT >= 19) {
    text ("sdCard0 file path = \n\n " + sdPath0 + "\n\n sdCard1 file path = \n\n " + sdPath1, 0, 0, width, height) ;
  } else if (Build.VERSION.SDK_INT >= 8) {
    text ("sdPath0 file path = \n\n"  + sdPath0, 0, 0, width, height) ;
  }
}

How can i start a new Activity from Processing IDE ?

$
0
0

Hi, as i said in the title of the thread, i need help to build a simple game in Processing. I made a menu, and, i would like to start the game in a new Activity. How can i do this with Processing (last version) ?

Sorry for my bad english. Thanks

Using the video library for an android app

$
0
0

Hello, My name is Varun Kumar. I am looking to propose an android app utilizing the current video app for a bigger project. I have been working with openGL, image and vision procsessing for a while now. It would be great if I could discuss about my proposal. You can either mail me to heysadboy@gmail.com or we can discuss here.

Exchange data...

$
0
0

I can't figure how to make possible communication between a PC and Cell phone using network !? which library I have to use? not to program the cell phone but to exchange data between both. Thanks

New beta release of the Android mode

$
0
0

Hi, a new beta release of the android mode is available for download. Two major changes:

Give it a try, and report issues on GitHub. Thanks!


How can i use google-play score service?

$
0
0

How can i use google-play score service?

(Please help me) Smartphone is related to screen control.

$
0
0

Display

PROCESSING GUIDES Hello.

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.

I have made this request many times. But there was no answer.

What I want to do is :.

-. Step 1: Execute the application created by processing.

-. Step 2: Press the power button. The screen goes out.

-. Step 3: The screen turns on with an event occurrence.

In other words, how can you make the screen with the cellphone screen turned off?

Requirement 1: I want to turn on when the screen of the cell phone is off.

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.

And I ask another one.

-. Step 1: Execute the application created by processing.

-. Step 2: Go to the desktop through the home button.

-. Step 3: A message appears after an event.

Requirement 2: Can I get a message from the home screen instead of the app's screen?

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.

I want the sample code to be available. Thank you very much. Help.

Processing 3.3 64 bit Android Mode : Error from inside the Android tools, check the console

$
0
0

I have tried to run my Processing code on my Android device. My device is successfully detected by Processing. But When I tried to run my code on my device, existed this error:

Error from inside the Android tools, check the console.

[mkdir] Created dir: C:\Users\Tianran\AppData\Local\Temp\android265366583508353702sketch\bin
 [echo] org.eclipse.jdt.core.JDTCompilerAdapter

BUILD FAILED
C:\Users\Tianran\AppData\Local\Temp\android265366583508353702sketch\build.xml:81:
  Cannot find C:\Users\Tianran\AppData\Local\Android\Sdk\tools\ant\build.xml
  imported from C:\Users\Tianran\AppData\Local\Temp\android265366583508353702sketch\build.xml

Total time: 0 seconds

Additional Infos, see comments.

How to install Android Mode pre-release correctly? Where is the detailed instruction?

$
0
0

According to http://android.processing.org/install.html

In order to do this, first download the AndroidMode-xyz.zip file for the desired release or pre-release from the releases section in the GitHub repo of the Android Mode. Uncompress the zip file and then move the AndroidMode folder into the modes folder inside inside the sketchbook folder.

This is very confusing for me. I have downloaded the Android Mode 0258 (https://github.com/processing/processing-android/releases) and tried to copy the main folder (renamed to "AndroidMode") to "modes" folder in Processing folder and it doesn't work.

Or maybe I understood this instruction wrongly? What does it mean " inside the sketchbook folder"?

Send arduino data to its application - Ketai libraries

$
0
0

Hello, the goal of my project is to control a laboratory arm that needs to take a methane bottle, I have to send on my tablet the methane content of the bottle. So here is my code processing and arduino:

Code Processing

` //Programme 2222

import controlP5.*; import android.content.Intent; import android.os.Bundle; import ketai.net.bluetooth.*; import ketai.ui.*; import ketai.net.*;

PFont fontMy; boolean bReleased = true; //Pas de changement d'état de la réponse si le doigt reste //appuyé sur l'écran. KetaiBluetooth bt; boolean isConfiguring = true; String info = ""; KetaiList klist; ArrayList devicesDiscovered = new ArrayList(); int c1,c2; float n,n1; PFont p = createFont("Arial",40); int sliderValue = 100; int c = 0; boolean ON_OFF = false; String methane = "";

ControlP5 cp5; Textarea myTextarea; Println console; Button b; Toggle t01;

void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); bt = new KetaiBluetooth(this); }

void onActivityResult(int requestCode, int resultCode, Intent data) { bt.onActivityResult(requestCode, resultCode, data); }

void setup(){

size(displayWidth,displayHeight);

orientation(LANDSCAPE);

cp5 = new ControlP5(this);

cp5.enableShortcuts();

myTextarea = cp5.addTextarea("consoleE") .setPosition(0, height/12) .setSize(width/2, height/4) .setFont(createFont("", 15)) .setLineHeight(14) .setColor(color(0)) .setColorBackground(color(186, 186, 186)) .setColorForeground(color(255, 100)) ; myTextarea = cp5.addTextarea("consoleP") .setPosition(0, height/3) .setSize(width/2, height/5) .setFont(createFont("", 15)) .setLineHeight(14) .setColor(color(0)) .setColorBackground(color(186, 186, 186)) .setColorForeground(color(255, 100)); console = cp5.addConsole(myTextarea);

cp5.addToggle("ON_OFF") .setPosition(width/21, height/1.2) .setSize(width/9,height/13);

cp5.addButton("Monter") .setPosition(width/1.4, width/21) .setSize(width/10,height/12); cp5.addButton("Descendre") .setPosition(width/1.4, width/6) .setSize(width/10,height/12); cp5.addButton("Gauche") .setPosition(width/1.67, width/9.5) .setSize(width/10,height/12); cp5.addButton("Droite") .setPosition(width/1.205, width/9.5) .setSize(width/10,height/12);

//Début de connexion Bluetooth. bt.start(); //Sélection de l'application. isConfiguring = true; //Couleur de fond fontMy = createFont("SansSerif", 40); textFont(fontMy); textSize(50); text("SHIPWARS", 280, 55);

}

void draw(){

//Si la sélection de l'application est valide. if (isConfiguring) { ArrayList names; background(78, 93, 75); klist = new KetaiList(this, bt.getPairedDeviceNames()); isConfiguring = false; } else { background(77, 73, 73); //Change le font de l'application //Affichage de la reception des données. fill(255); noStroke(); textAlign(LEFT); text(info, 20, 104); }

noStroke();

fill(0); textSize(20); text("Connexion bluetooth: ", 5, height/20);

fill(0); textSize(20); text("Taux de méthane: " + methane + " ppm", width/7, height/1.6); text("Alerte: ", width/6.4, height/1.4); fill(255); ellipse(width/3.5, height/1.42, width/28, height/17.3);

stroke(0); fill(255);

//Placement de joystick noStroke();

fill(255); noStroke(); //Côter gauche rect(width/2,0,width/200 ,height); //Ligne 1 fill(255); rect(0, height/13.5, width/2, height/120); //Ligne 2 fill(255); rect(0, height/1.88, width/2, height/120); //Ligne 3 fill(255); rect(0, height/1.3, width/2, height/120); //Côter droite //Ligne 1 fill(255); rect( width/2,height/2.3, width/2, height/120);

noStroke();

if(ON_OFF){ //Envoie des données bluetooth byte[] data = {'a','l','l','u','m','e','\r'}; bt.broadcast(data); //Premier envoi "eteint". bReleased = false; if(mousePressed == false) { bReleased = true; } fill(0, 255, 0); ellipse(width/5, height/1.15, width/28, height/17.3); fill(255); ellipse(width/3.2, height/1.15, width/28, height/17.3);

} else { byte[] data = {'e','t','e','i','n','t','\r'}; bt.broadcast(data); //Premier envoi "eteint". bReleased = false; if(mousePressed == false) { bReleased = true; } fill(255); ellipse(width/5, height/1.15, width/28, height/17.3); fill(255, 0, 0); ellipse(width/3.2, height/1.15, width/28, height/17.3);

} } void onKetaiListSelection(KetaiList klist) { String selection = klist.getSelection(); bt.connectToDeviceByName(selection); //Présence d'une Liste. klist = null; }

//Méthode de gestion des évenements (dans la librairie Ketai), permettant de //recevoir les données. void onBluetoothDataEvent(String who, byte[] data) { if (isConfiguring) return; //Réception. info += new String(data); //Effacer si le mot trop long. if(info.length() > 150) info = "";

methane += new String(data); //Effacer si le mot trop long. if(methane.length() > 150) methane = ""; } public void controlEvent(ControlEvent theEvent) { println(theEvent.getController().getName()); n = 0; } public void consoleE(int theValue){

} public void consoleP(int theValue){

}`

Code Arduino :

`//fw commenté le 22/06/2015. //Led pin 13 commandée IHM Bluetoothandroid Bp arduino //et affigage du message des états de la LED;

include <SoftwareSerial.h>

include <LiquidCrystal.h> //Introduction de la bibliothèque

SoftwareSerial mySerial(12,7); // RX, TX en (10,7)...

char chByte = 0; // Byte arrivant reçu. String strInput = ""; // Contenu dans l'octet. String Led_Rouge = "eteint";//5 caractéres (5 lignes). String Led_Verte = "allume";//5 caractéres (5 lignes).

const int AOUTpin = A0; //the AOUT pin of the methane sensor goes into analog pin A0 of the arduino int methane; // déclaration de la variable

void setup() { mySerial.begin(9600); //Vitesse RS232 9600 Bauds //vérifier que le débit utilisé est le même que dans le terminal série. pinMode(13, OUTPUT); //Affectation led pin 13 en sortie. pinMode(5, OUTPUT); pinMode(2, OUTPUT); Serial.begin(9600); }

void loop() { while (mySerial.available() > 0)//Octets positifs présents dans la file d'attente //série. {

chByte = mySerial.read();//Lire les 8 bits présents dans la variable "chByte". if (chByte == '\r') { //Comparaison du message en début d'octet. if(strInput.equals(Led_Rouge)) { digitalWrite(13, HIGH);//Alors allumer la led en pin 13. delay(3000);//Délai d'allumage de la LED avant extinction. digitalWrite(13, LOW);//Alors eteindre la led en pin 13. }

else if(strInput.equals(Led_Verte)) { digitalWrite(5, HIGH);//Alors allumer la led en pin 13. delay(3000);//Délai d'allumage de la LED avant extinction. digitalWrite(5, LOW);//Alors eteindre la led en pin 13. } //Effacer le mot contenu en début d'octet. strInput = ""; } else { strInput += chByte; } } Serial.print("A0:"); Serial.println(analogRead(AOUTpin)); methane = analogRead(AOUTpin); //reads the analaog value from the methane sensor's AOUT pin methane = methane5/102350; //convertis la valeur
Serial.println(methane); delay(1000); }`

Android Processing, Bluetooth and Wi-Fi connectivity

$
0
0

Will processing be able to adapt codes for Bluetooth and Wi-Fi Connectivity in creation of GUIs? Which can be used in communication or controlling of arduino projects?

Trouble in android mode, using "loadImage()" & "orientation(LANDSCAPE)"?

$
0
0

Hello I am new to processing. I am having trouble with processing in the android mode, using "PImage" and "loadImage" when I choose "orientation(LANDSCAPE);". My simplyfied Code:


     import java.util.*;  //To use ArrayList
    ArrayList<PImage> bilder_a;

    void setup() {
      fullScreen();
      orientation(LANDSCAPE);
      background(0);

      //Load Pictures:
      bilder_a=new ArrayList<PImage>();
      int pic_anzahl=9;
      String pic_name;
      for (int i=0; i<=pic_anzahl; i++)
      {
        pic_name="pic_a"+i+".JPG";
        bilder_a.add(loadImage(pic_name));
      }
    }

I use the newest stable Version of processing, 3.3 and the newest and stable Version of SDK for Windwos 10, 64Bit. I already reinstalled the two, to see whether there is a software failure. But it does not solve anything. In my Sketch folder, I have the "data" folder with all the pictures... I am using an Oukitel K10000. My code works fine, when I run it in Java-Mode, but fails in Android-Mode:

-post-build:

debug: FATAL EXCEPTION: Animation Thread Process: processing.test.trouble, PID: 11536 java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.AssetManager android.app.Activity.getAssets()' on a null object reference at processing.core.PApplet.createInputRaw(Unknown Source) at processing.core.PApplet.createInput(Unknown Source) at processing.core.PApplet.loadImage(Unknown Source) at processing.test.trouble.trouble.setup(trouble.java:36) at processing.core.PApplet.handleDraw(Unknown Source) at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source) at processing.core.PApplet.run(Unknown Source) at java.lang.Thread.run(Thread.java:818) [The application does not crash, when I start it with my smartphone turned to the right landscape mode, but that is obviously not a solution...]

The strange thing is..., the Code works fully-fine even in Android-Mode, when I delete the line "orientation(LANDSCAPE);" or when i delete the line "bilder_a.add(loadImage(pic_name));". I know, the LANDSCAPE and PImage-stuff had been discussed like a thousand times.. but I never found a discussion, that focuses, the combination of LANDSCAPE and PImage, which obviously makes me trouble.

I hope you can help me, thanks a lot by now!


Editing Manifest File

$
0
0

Hi, I am working on uploading my app the the Play store. I want to restrict screen sizes that my app will display to by adding code to the manifest file. I have tried editing the AndroidManifest.xml file in the sketch folder. However, it appears that the file is automatically generated, because after I create the signed .apk file my changes to the manifest file are no longer visible. How can I edit the manifest file so that my .apk will take the changes? Any suggestions would be appreciated.

APDE application after export apk for Android is not installed

$
0
0

APDE application after export apk for Android is not installed. In APDE working. Prompt please the reason.

Using Android Studio - How to I load media files...

$
0
0

Hi everyone,

Thanks for taking the time to read this. I'm using Android Studio to package my processing sketches as outlined here.

I have a basic test sketch working fine which simply draws ellipses on screen. However, I'm having issues loading images and other media files, usually they would go into the data folder (I'm more used to p5.js in which case I put them into an assets folder and load them using relative URLs).

Where do I need to put images/mp3s within my android project so that I can load them using PImage and loadImage with processing?

If anyone can help I would greatly appreciate it.

Thanks,

Matt

How to set parameters of a live wallapper?

$
0
0

I 've coded some live wallappers with processing. However the parameters are fixed (for example the size of a ball); How can a normal app set them through user input?

How to use flashlight ?

$
0
0

Hi, I want to light up my flashlight when i press a button (for exemple) but i don't know how to do :(( Help me please !

Viewing all 941 articles
Browse latest View live