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

Call android keyboard doesn't work

$
0
0

hi, I've tried to run keyboard on android and I get an error. the error is: the function getSystemService does not exist. here is the code.

import android.view.inputmethod.InputMethodManager;
import android.content.Context;
boolean showing=false;

void setup() {
  fullScreen();
}

void draw() {
  if (showing)
    showVirtualKeyboard();
  else
    hideVirtualKeyboard();
}

void mousePressed() {
  showing=true;
}

void showVirtualKeyboard() {
  InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
  imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}

void hideVirtualKeyboard() {
  InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
  imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
}

anybody knows why?


how to receive data in arduino from android Device with bluetooth

$
0
0
    hi everybody

    has anyone used the BluetoothCursors.pde example in processing android mode with arduino ?

    the code in the example sends the X/Y of the cursor on the android device to the arduino over Bluetooth with the keitai library.
    the funktion to send the data from the android device to arduino ist the bt.broadcast() funktion.
    both codes work with no errors but i can not recognize the data correctly, i got some wierd numbers when i print the X and Y on the  arduino IDE.

    i think the code on the arduino is not correct.
    i attached the processing code and arduino code so if someone has experinece with this , could probably hepl

    thanks guys


    Processing code 1:
    /**
     * <p>Ketai Library for Android: http://KetaiProject.org</p&gt;
     *
     * <p>KetaiBluetooth wraps the Android Bluetooth RFCOMM Features:
     * <ul>
     * <li>Enables Bluetooth for sketch through android</li>
     * <li>Provides list of available Devices</li>
     * <li>Enables Discovery</li>
     * <li>Allows writing data to device</li>
     * </ul>
     * <p>Updated: 2012-05-18 Daniel Sauter/j.duran</p>
     */

    //required for BT enabling on startup
    import android.content.Intent;
    import android.os.Bundle;

    import ketai.net.bluetooth.*;
    import ketai.ui.*;
    import ketai.net.*;

    import oscP5.*;

    KetaiBluetooth bt;
    String info = "";
    KetaiList klist;
    PVector remoteMouse = new PVector();

    ArrayList<String> devicesDiscovered = new ArrayList();
    boolean isConfiguring = true;
    String UIText;


    //********************************************************************
    // The following code is required to enable bluetooth at startup.
    //********************************************************************
    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()
    {
      fullScreen();
      orientation(PORTRAIT);
      background(78, 93, 75);
      stroke(255);
      textSize(56);

      //start listening for BT connections
      bt.start();

      UIText =  "d - discover devices\n" +
        "b - make this device discoverable\n" +
        "c - connect to device\n     from discovered list.\n" +
        "p - list paired devices\n" +
        "i - Bluetooth info";
    }

    void draw()
    {
      if (isConfiguring)
      {
        ArrayList<String> names;
        background(78, 93, 75);

        //based on last key pressed lets display
        //  appropriately
        if (key == 'i')
          info = getBluetoothInformation();
        else
        {
          if (key == 'p')
          {
            info = "Paired Devices:\n";
            names = bt.getPairedDeviceNames();
          }
          else
          {
            info = "Discovered Devices:\n";
            names = bt.getDiscoveredDeviceNames();
          }

          for (int i=0; i < names.size(); i++)
          {
            info += "["+i+"] "+names.get(i).toString() + "\n";
          }
        }
        text(UIText + "\n\n" + info, 5, 90);
      }
      else
      {
        background(78, 93, 75);
        pushStyle();
        fill(255);
        ellipse(mouseX, mouseY, 20, 20);
        fill(0, 255, 0);
        stroke(0, 255, 0);
        ellipse(remoteMouse.x, remoteMouse.y, 20, 20);
        popStyle();
      }

      drawUI();
    }


    //Call back method to manage data received
    void onBluetoothDataEvent(String who, byte[] data)
    {
      if (isConfiguring)
        return;


      //KetaiOSCMessage is the same as OscMessage
      //   but allows construction by byte array
      KetaiOSCMessage m = new KetaiOSCMessage(data);
      if (m.isValid())
      {

        if (m.checkAddrPattern("/remoteMouse/"))
        {
          if (m.checkTypetag("ii"))
          {

            remoteMouse.x = m.get(0).intValue();
            remoteMouse.y = m.get(1).intValue();
           // text(mouseX,50,100);
             //text(mouseY,50,100);


          }

        }
      }
    }

    String getBluetoothInformation()
    {
      String btInfo = "Server Running: ";
      btInfo += bt.isStarted() + "\n";
      btInfo += "Discovering: " + bt.isDiscovering() + "\n";
      btInfo += "Device Discoverable: "+bt.isDiscoverable() + "\n";
      btInfo += "\nConnected Devices: \n";

      ArrayList<String> devices = bt.getConnectedDeviceNames();
      for (String device: devices)
      {
        btInfo+= device+"\n";
      }

      return btInfo;
    }


    Second Tab in the processing Code:

    /*  UI-related functions */


    void mousePressed()
    {
      //keyboard button -- toggle virtual keyboard
      if (mouseY <= 50 && mouseX > 0 && mouseX < width/3)
        KetaiKeyboard.toggle(this);
      else if (mouseY <= 50 && mouseX > width/3 && mouseX < 2*(width/3)) //config button
      {
        isConfiguring=true;
      }
      else if (mouseY <= 50 && mouseX >  2*(width/3) && mouseX < width) // draw button
      {
        if (isConfiguring)
        {
          //if we're entering draw mode then clear canvas
          background(78, 93, 75);
          isConfiguring=false;
        }
      }
    }

    void mouseDragged()
    {
      if (isConfiguring)
        return;

      //send data to everyone
      //  we could send to a specific device through
      //   the writeToDevice(String _devName, byte[] data)
      //  method.
      OscMessage m = new OscMessage("/remoteMouse/");
      m.add(mouseX);
      m.add(mouseY);

      bt.broadcast(m.getBytes());


      textAlign(RIGHT);
      text(mouseY,200,100);
      textAlign(LEFT);
    text(mouseX,50,300);
    //text (OscMessage,50,700);

      ellipse(mouseX, mouseY, 20, 20);
    }

    public void keyPressed() {
      if (key =='c')
      {
        //If we have not discovered any devices, try prior paired devices
        if (bt.getDiscoveredDeviceNames().size() > 0)
          klist = new KetaiList(this, bt.getDiscoveredDeviceNames());
        else if (bt.getPairedDeviceNames().size() > 0)
          klist = new KetaiList(this, bt.getPairedDeviceNames());
      }
      else if (key == 'd')
      {
        bt.discoverDevices();
      }
      else if (key == 'x')
        bt.stop();
      else if (key == 'b')
      {
        bt.makeDiscoverable();
      }
      else if (key == 's')
      {
        bt.start();
      }
    }


    void drawUI()
    {
      //Draw top shelf UI buttons

      pushStyle();
      fill(0);
      stroke(255);
      rect(0, 0, width/3, 50);

      if (isConfiguring)
      {
        noStroke();
        fill(78, 93, 75);
      }
      else
        fill(0);

      rect(width/3, 0, width/3, 50);

      if (!isConfiguring)
      {
        noStroke();
        fill(78, 93, 75);
      }
      else
      {
        fill(0);
        stroke(255);
      }
      rect((width/3)*2, 0, width/3, 50);

      fill(255);
      text("Keyboard", 5, 30);
      text("Bluetooth", width/3+5, 30);
      text("Interact", width/3*2+5, 30);

      popStyle();
    }

    void onKetaiListSelection(KetaiList klist)
    {
      String selection = klist.getSelection();
      bt.connectToDeviceByName(selection);

      //dispose of list for now
      klist = null;
    }




    arduino sketch using HC-06:


    #include <SoftwareSerial.h>

    SoftwareSerial BT(10, 11);

    int delayval = 100;

    int xVal = 0;
    int yVal = 0;

    void setup() {


    // set the data rate for the SoftwareSerial port


      Serial.begin(9600);
      BT.begin(9600);

    }



    void loop() {

          if (BT.available()) ;  // Wait here until input buffer has a character
      {

      }

     x = BT.read();

        y = BT.read();

    Serial.print(x); Serial.print("---------------"); Serial.println(y);
    }

I can not connect to the internet

$
0
0

Hi. I'm writing a little app to view the online comics. When you attempt to display an image error takes off:

java.lang.SecurityException: Permission denied (missing INTERNET permission?) at java.net.InetAddress.lookupHostByName(InetAddress.java:430) at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236) at java.net.InetAddress.getAllByName(InetAddress.java:214) at libcore.net.http.HttpConnection.<init>(HttpConnection.java:70) at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50) at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340) at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87) at libcore.net.http.HttpConnection.connect(HttpConnection.java:128) at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:316) at libcore.net.http.HttpEngine.connect(HttpEngine.java:311) at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:290) at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:240) at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:81) at processing.core.PApplet.createInputRaw(Unknown Source) at processing.core.PApplet.createInput(Unknown Source) at processing.core.PApplet.loadImage(Unknown Source) at processing.test.otladka1.otladka1.setup(otladka1.java:24) 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:838) Caused by: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname) at libcore.io.Posix.getaddrinfo(Native Method) at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:59) at java.net.InetAddress.lookupHostByName(InetAddress.java:405) ... 20 more Caused by: libcore.io.ErrnoException: getaddrinfo failed: EACCES (Permission denied) ... 23 more

I use Processing 3.1.2 and AndroidMod 4.0. Test program by connecting the mobile phone. In the JAVA mode, everything works fine. And here is the code:

`PImage webImg;

void setup() { fullScreen(); webImg=loadImage("http://xkcd.ru/i/968_v6.png");
}

void draw() { image(webImg, 0, 0); } `

Why PImage didnt work after making standalone app? (android)

$
0
0

When i compiling my programm in processing PImage is working correctly, but when i making standalone app, PImage doesnt work in it

Control Swipes

$
0
0

anybody knows how to control swipes in android mode? any example of this?

Android emulator mode not working on mac osx yosemite

$
0
0

I have a fresh install of processing and an updated java. I let processing load the android mode and then it asked to downlload the android emulator. this is a mid 2012 macbook pro running osx yosemite and latest download of processing 3.

when I go to the AVM manger and tell it to start manually I get the following output text:

Starting emulator for AVD 'Processing-0217' emulator: WARNING: VM heap size set below hardware specified minimum of 384MB emulator: WARNING: Setting VM heap size to 768MB emulator: ERROR: x86 emulation currently requires hardware acceleration! Please ensure Intel HAXM is properly installed and usable. CPU acceleration status: HAXM is not installed on this machine

I'm testing a helloworld script to see if it works and I get the following error message: "lost connection while device launching. try again"

debug: Emulator process exited with status 1. EmulatorController: Emulator never booted. NOT_RUNNING Error while starting the emulator. (NOT_RUNNING) Shutting down any existing adb server...

When I got to the AVM manager and tell it to start manually

Setting font size?

$
0
0

Just started running a sketch on an Android phone. So far so good with one exception. I'm putting some progress statistics in area above the main action and have not found the magic to increase font size. Above setup() "PFont f;" is declared and in setup() I state "f = createFont("Arial", 48, true);". In draw() I call: textFont(f, 48); fill(0); textAlign(LEFT); text("bunch of stuff", x, y);

What appears in the Canvas during execution is always a small font size. I have also tried SansSerif and SansSerif-Bold. Is there a forum discussion I couldn't find? Or can someone give me a hint? Thanks...

How to make loading animation

$
0
0

Hi, I've done an application which has lot of data to load. So I need a way to load this data in background. I've tried with threads but it is not working. Any other way?


ICON Change ?

$
0
0

how can i change the icon for my android and pc applications

Save files to data folder

$
0
0

How can I save files like JSON files to the data folder in android?

Front-Camera on Android?

$
0
0

Hi at all!

Has anyone a working solution using the Front-Camera in Android? I've already searched the hole web, and Ketai is unfortunately not working....

Thanks in advance

Counting time on screeen while app is running

$
0
0

Hello Guys. I am new to processing and programming in general. I am trying to design a small software and i need it to count and display time on the screen while the app is running on the android phone. Any ideas on this. Thank you in Advance

Sound analysis on input from microphone on Android device

$
0
0

Hi

I have gotten a request for a sound reactive project for Android phones. I want to read the incoming audio from the microphone on the Android device and animate the graphics based on the sound - potentially via a FFT analysis. I know how to do it on desktop using FFT analysis in Processing using the build in sound library or FFT in Processing using minim but is this possible in Android mode?

It seems like Minim does not work in Android mode, but perhaps you guys can point me towards another approach or library? Or can I just use Processings build in sound library directly?

Cheers Andreas

How to display StatusBar ?

$
0
0

Hi guys, Im using APDE during long time to create sketches for little programs. I try to create my own program with android face. Well my first problem was using the keyboard but i fixed it, but now i have problem to display StatusBar :/

I know i can do it by using this method :

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); }

The problem is ... for APDE getWindow() is an undefined method. OK i know i need to change something in androidManifest.xml to display the Fullscreen to use this method, but anyways for APDE getWindow() is an undefined method.

THX for any helps !

How to work in andoid with controlP5? Make bigger labels and use keyboard?

$
0
0

Hi! I have some trouble working with controlP5 and android. I have some scrollable lists and their "head" or "label" size is small. I have make bigger letters but background size is still small. Also how to show keyboard when a textfield is clicked/touched? And third question is, how to make a part of the field scrollable? Something like a menu or small scrollable window?


Build Error inside the Android Tools

$
0
0

Hi,

I am a newbie with Processing and I tryed to use the Android Mode.

After installing it following instruction at android.processing.org, I found that the example (at android.processing.org/tutorials/getting_started/index.html ) doesn't work.

This error appear into the console:

ERROR in C:\Users\me\AppData\Local\Temp\android2462465000772794310sketch\src\processing\test\sketch_160822b\MainActivity.java (at line 58) public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The method onRequestPermissionsResult(int, String[], int[]) of type MainActivity must override a superclass method

I don't know what it's mean and how to fix it.

thanks to anyone who can help me.

other info:

I'm using the 3.2 version of processing on Windows(x64).

send files using bluetooth

$
0
0

hi i'm trying to send files as "photos" via bluetooth using ketai library and i'm completely lost !!, so is there any help

OBJ Export with nervoussystem on Android with version 3.2.1 of Processing?

$
0
0

Hi guys. I'm new to this forum but i know processing since version 2. Now i started learn it and got a big problem with my code for android. Here's my code:

import nervoussystem.obj.*;
boolean record = false;

void setup() {
  size(400, 400,P3D);
}

void draw() {
  if (record) {
    beginRecord("nervoussystem.obj.OBJExport", "filename.obj");
  }
  beginShape();
  vertex(-100, -100, -100);
  vertex( 100, -100, -100);
  vertex(   0,    0,  100);

  vertex( 100, -100, -100);
  vertex( 100,  100, -100);
  vertex(   0,    0,  100);

  vertex( 100, 100, -100);
  vertex(-100, 100, -100);
  vertex(   0,   0,  100);

  vertex(-100,  100, -100);
  vertex(-100, -100, -100);
  vertex(   0,    0,  100);

  if (keyPressed)
  {
    if (key == 'b' || key == 'B')
    {
      vertex (-200, 200, -100);
    }
  }

  endShape();
  if (record) {
    endRecord();
    record = false;
  }
}

void mousePressed() {
  record = true;
}

I've got errors with the functions: beginRecord() and endRecord(). Processing says that the functions aren't exist, but on the java mode it works well. This library means much to me for the beginning, so, are there any solutions to solve this problem? Or do i have to write my own library? Thanks in advance ;) Greetings Argandos

Unfolding Maps in Android

$
0
0

Hello, I'm checking out Unfolding Maps in Android mode, trying the SimpleMapApp example in the installation. (Runs in Java mode for me with no problems.)

I'm using Processing 2.2.1 (Processing 3.x is similar), exporting to Nexus 7 (2012) running Android 4.4.2. So far all the other Processing-Android libraries etc I've tried work fine. But the SimpleMapApp gives me this error message:

Unfolding Map v0.9.6 No OpenGL renderer. Using Java2DMapDisplay. FATAL EXCEPTION: Thread-923 Process: processing.test.simplemapapp, PID: 30496 java.lang.NoSuchMethodError: processing.core.PApplet.loadImage at de.fhpotsdam.unfolding.tiles.TileLoader.getTileFromUrl(Unknown Source) at de.fhpotsdam.unfolding.tiles.TileLoader.run(Unknown Source) at java.lang.Thread.run(Thread.java:841)

After TileLoader.java in the source distribution, looks like this (and another call to loadImage) is the problem:

PImage img = p.loadImage(urls[0], "unknown");

Is there a version of Unfolding Maps with this fixed? Before I try to tinker with it and recompile the library…

Thanks! Bill

Android App only 100x100.

$
0
0

Hey, I'm having a problem where my standard canvas size (without size() method) is only 100x100, and I also can't change it with size(). On a new sketch with size() and background() set it works, but not with my app. I also tried to comment out basically everything. Didn't have this problem before. I think it started when I updated processing and android-mode. Can someone help? cheers

Viewing all 941 articles
Browse latest View live