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

Android Mode Won't Install

$
0
0

I tried to install Android Mode on Processing 3, and it didn't load and kept displaying a message saying that it won't load. How can I install Android Mode without this happening?


Video in Android Mode

$
0
0

Hello I am trying to make a project and the first hurdle is making it sense when a viewer is present and play the video/pause video when viewer leaves. I have searched extensively through the forums and other parts of the net and I can't find any code new enough that it is working for me. I am running Processing 3 and I am currently building onto a Samsung Galaxy Tab 3 running 4.4.2. My instincts say that this will be too slow and I will need to figure out how to do it in Java/Eclipse for speed sake, but I wanted to try this first.

Does anyone have any code for efficient video playback that is working for them in Processing 3 Android mode?

Thanks!

strange error when exporting apk with P3

$
0
0

i have tried to export an apk with P3xx, OS X yosemite error is:: "java.io.IOException: Cannot run program "/Users/username/Developer/android-sdk-macosx/build-tools/.DS_Store/zipalign": error=20, Not a directory --- which is sure! .DS_Store is not a directory! - But on OS X it is present and you cannot delete it (or you have to delete all of them with terminal and this could be a cause for multiple OS X errors). I see no way to solve that... thanks in advance

Edit:: i have tested with the same code in Eclipse, the export is done && in the console i see "ignoring .DS_Store"...

Android Twitter4j

$
0
0

Hi everyone,

I'm trying to get twitter stream on my android nexus4 with twitter4j. On processing version 2.2.1, it work perfectly ! but i can't upload my sketch to my device on processing 3.* and got this error :

i tried sdk 18 -> 23 and none works with processing 3.07

CODE

I used this exemple to test the lib https://github.com/neufuture/SimpleTwitterStream

And i don't where the error come from , processing, lib or android sdk ?

thanks for reading :) , T.

PS : Other sketch compile perfectly on my phone with processing 3

Context, this, and Activity ... P3

$
0
0

A few recent posts about P3 issues have the following lines of code (from akenaton) as solution to obtaining context/activity info etc, but they are giving me an error.

The error I am getting is saying that "the function getActivity() does not exist"

import android.content.Context; import android.app.Activity;

Context context;
Activity act;

void setup() {
  act = this.getActivity();
  context = act.getApplicationContext();
}

void draw() {
}

I could have stayed in one of the current discussions but as this goes across a few I hope another discussion thread is OK!?

a ketai library test with bluetooth of my phone doesn't work

Test BluetoothCursors of device

$
0
0

Hello i trie tu test a examle from Ketai library, the name ist BluetoothCursors of samsung device Android 4.4.2. But i don t understand , why, i can not test of the phone. Can somewhere help me please hier ist the code

/** *

Ketai Library for Android: http://KetaiProject.org

* *

<

p>KetaiBluetooth wraps the Android Bluetooth RFCOMM Features: *

    *
  • Enables Bluetooth for sketch through android
  • *
  • Provides list of available Devices
  • *
  • Enables Discovery
  • *
  • Allows writing data to device
  • *
  • Updated: 2012-05-18 Daniel Sauter/j.duran

    */

//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 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() {
orientation(PORTRAIT); background(78, 93, 75); stroke(255); textSize(24);

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

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 devices = bt.getConnectedDeviceNames(); for (String device: devices) { btInfo+= device+"\n"; }

return btInfo; }

Getting the raw MotionEvent

$
0
0

Just posting this if someone else is battling with this. I needed to get the raw events from Android so I could implement Stylus commands for drawing - this worked before when the sketch was extended from the Activity - now that the sketch extends from PApplet, the dispatchTouchEvent(MotionEvent) method might not work, or at least I didn't find a safe way to get it working.

So, to grab the events, use the PApplet's own method nativeMotionEvent(MotionEvent):

@Override
protected void nativeMotionEvent (MotionEvent event) {

     // You can now catch the events and parse them
}

Example:

@Override
protected void nativeMotionEvent (MotionEvent event) {

    // InputNode is a custom class that just stores the values
    InputNode node;
    
    int pointerType = event.getToolType(0);


    int actionType = event.getActionMasked(); 

    if (actionType == MotionEvent.ACTION_DOWN)
    {
        println("Input_Android: Pointer is down, checking GUI hit.");
        gui.GUI_Hit(event.getX(), event.getY());
    }



    int historySize = event.getHistorySize(); 

    for (int i = 0; i < historySize - 1; i++)
    {
        if (historySize > 0)
        {
            node = new InputNode(); 
            node.x = event.getHistoricalX(0, i);
            node.y = event.getHistoricalY(0, i);
            node.pressure = event.getHistoricalPressure(0, i);
            node.size = event.getHistoricalSize(0, i);
            node.pointerAction = event.getActionMasked();
            node.pointerType = pointerType;

            inputModifier.Process(node);
        }
    }



    node = new InputNode(); 
    
    pointerType = event.getToolType(0);

    // MotionEvent.POINTER_TYPE_UNKNOWN = 0;
    // MotionEvent.POINTER_TYPE_FINGER  = 1;
    // MotionEvent.POINTER_TYPE_STYLUS  = 2;
    // MotionEvent.POINTER_TYPE_MOUSE   = 3;
    // MotionEvent.POINTER_TYPE_ERASER  = 4;

    node.x = event.getX(0);
    node.y = event.getY(0);
    node.pressure = event.getPressure(0);
    node.size = event.getSize(0);
    node.pointerAction = event.getActionMasked();
    node.pointerType = pointerType;

    inputModifier.Process(node);

}

How to hide the bottom menu of Android?

$
0
0

Hi everyone!!

When I run the aplication, in the screen of the smartphone appears the navigation bar (return, home, settings buttons and black background). I modified the manifest.xml, use the sketch permissions, and other code with onCreate() functions, but nothing works. there any way to hide the navigation bar?

I read this: https://developer.android.com/training/system-ui/navigation.html But I don't understand how it works because it's my first time, programing with android. I'm using Android 5.1.1, and Processing 3.0 and the last version of android mode. Sorry for my bad English.

Thanks a lot!

Using class EditText with processing?

$
0
0

Hello,

I have this looking everywhere for a simple way to write and edit text strings in android.

I tried using the controlP5 library, but does not affect the virtual keyboard keystrokes.

I think what I want can be done with editext, but my code does not work, any ideas?

import android.widget.EditText;
   import android.view.inputmethod.InputMethodManager;
    import android.inputmethodservice.KeyboardView.OnKeyboardActionListener;
    import android.view.KeyEvent;
    import android.view.View;
    import android.util.DisplayMetrics;
    import android.net.wifi.WifiInfo;
    import android.net.wifi.WifiManager;
   import android.content.Context;
   import android.content.pm.ActivityInfo;
   import android.content.SharedPreferences;
   import android.content.SharedPreferences.Editor;

  // EditText myEditText =  (EditText) findViewById(R.id.vnosEmaila);
import controlP5.*;
EditText txt1;
   InputMethodManager imm;
ControlP5 cp5;

String textValue = "";
String textValue2 = "";
void setup() {

 txt1 = (EditText)findViewById(R.id.text);


  size(700,400);

  PFont font = createFont("arial",20);

  cp5 = new ControlP5(this);

  cp5.addTextfield("input")
     .setPosition(20,100)
     .setSize(200,40)
     .setFont(font)
     .setFocus(true)
     .setColor(color(255,0,0))
     ;

  cp5.addTextfield("textValue")
     .setPosition(20,170)
     .setSize(200,40)
     .setFont(createFont("arial",20))
     .setAutoClear(false)
     ;

  cp5.addBang("clear")
     .setPosition(240,170)
     .setSize(80,40)
     .getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER)
     ;    

  cp5.addTextfield("default")
     .setPosition(20,350)
     .setAutoClear(false)
     ;

  textFont(font);
}

void draw() {if(mousePressed == true){showVirtualKeyboard();delay(888);}
  background(0);
  fill(255);
try{textValue2 = txt1.getText().toString();  }catch(Exception e){}
//  if(key != 0){textValue=textValue+key;text(cp5.get(Textfield.class,"input").getText(), 360,130);key = 0;}
  text(textValue2, 360,180);//text(input, 460,180);
}

public void clear() {
  cp5.get(Textfield.class,"textValue").clear();
}

void controlEvent(ControlEvent theEvent) {
  if(theEvent.isAssignableFrom(Textfield.class)) {
    println("controlEvent: accessing a string from controller '"
            +theEvent.getName()+"': "
            +theEvent.getStringValue()
            );
  }
}

  public void showVirtualKeyboard() 
  {
    //LIMPIEZA     teclado_ON = 0; 
              InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
              imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
    //    image(fondo, 0, 0);
  }

public void input(String theText) {
  // automatically receives results from controller input
  println("a textfield event for controller 'input' : "+theText);
}

greetings and thanks in advance

Can't open Processing 3.0 due to Android mode

$
0
0

I just downloaded Processing 3.0 and after clicking on the application, I get this pop up:

mode out of date

I would love to update the mode if that will help me, but it won't let me open Processing. I would like some help :)

USB communication Arduino Pro Micro / Leonardo and Android

video with P3

$
0
0

with P2, w or without Eclipse I can show video, using standard android code.

with P3, trying to answer on this forum i have tried my usual snippet code:: does not work now.

So i have tried a lot of solutions and finally got the video file to be found (not so easy...)

&& make the video sound appeared... what a luck:: but not image.

so (as i know that i am in a fragment and PApplet is only an object)

--- try to create another fragment (child, innested)

--- result is : activity destroyed, why, i don't know, i have done that with android and innested fragments does not destroy the activity...

---so another solution was: get SurfaceView and set MediaPlayer instance to this one

--- so another solution was:: creating new SurfaceView on runtime...

----ALWAYS the same: sound but not any image (and in some case, nothing, not any error, not any image, nothing)

i have also tried with videoView, with this.getView(), and so on

nothing works!!! -

For better i can see the video for 1 second ( so i know that video is playing) but the processing surface goes upon

So my question is very simple:: how to make video with P3??? (and real devices)

I do not know how to make a build clean in the Processing Development Environment 3. Can I do this?

$
0
0

Recently, I downloaded Android version 6.0 to my phone and then updated my Android SDK. I made something and runs good. But my past projects' console sayings are debug: Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED] Shutting down any existing adb server... Is there an easy option to clean, rebuild or something I do not know to run my code on the phone? I think there is like a path to the last version on this projects. I know an easy option will be copy-paste to a text file, delete the folder's project, create a new one with the same name, and then copy-paste to the PDE sketch's editor. But I need another solution like "delete this file inside this folder" or "press that button" or "type on the sketch this". Share your needed knowledge and I will be grateful. :)

Responsive Design/Media Query/Different mobile display sizes

$
0
0

Hello, im making an app for doing pixel art using mobiles. I own a Motorola Moto G and did the whole layout for my screen (729x1184 pixels) just to decide what goes where but now that its done I cant figure how to make it responsive to different screen sizes. I have tried using, for example, width/16 as the size for each "pixel" and make a 16x16 grid for drawing, but (examples):

if I use this nothing appears at the screen

int tam = width/16;

void setup(){

int cor = 0;

for (int i = 0; i < 16; i++){

fill(cor, 0 , 0);

rect(cor, 0, tam, tam);

cor += tam;

}

}

if I do this it works

void setup(){

int tam = width/16;

int cor = 0;

for (int i = 0; i < 16; i++){

fill(cor, 0 , 0);

rect(cor, 0, tam, tam);

cor += tam;

}

}

does that mean I will have to create a variable inside the scope its going to be used for every variable that needs to be responsive? It doesnt look right...

Another question, is there any way to ask the device for its screen size? In this case I have some buttons underneath the drawing matrix (like turning grid on/off, color palete and others) wich will have to be a button to a popup windows depending on the screen size (a button called palete that makes the color palete pops up for example). In this case, if the drawing matrix occupies more then a certain percentage of the screen height, considering the size of the matrix as the size of the screen width, as each drawable "pixel" has width/16 and the matrix is 16x16, the layout will be completely different from mobiles with screen sizes that fit the whole thing.

Any tips? Solutions? Anyone facing the same problem?

thanks in advance


Error from inside Android Tool

$
0
0

Hallo , everybody i have some mistake , i use Processing 2 and I want to test BluetoothCursors from ketai Library on my Android Device but i have some mistake when i compile. There is:

BUILD FAILED C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:716: The following error occurred while executing this line: C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:730: Error running javac.exe compiler

Thanks to help me, i am very new with Processing Android

Where or how is it possible (if it is...) to add some layout to an app with P3???

$
0
0

with Eclipse with or without P3 i can easily , from xml or from code, add a layout to an app. I have tried to do the same with P3 (coding) with this simple code (importing what is needed)

             Activity act;

            act = this.getActivity() // which is "said" an error by P3, i dont understand why as this is the way to do in a fragment
            //yet does not matter as it compiles....

            layout = new LinearLayout(act);

                tv = new TextView(act);
            layout.setLayoutParams(new ViewGroup.LayoutParams(-1,-1));
                tv.setLayoutParams(new ViewGroup.LayoutParams(-1,-2));
                 tv.setText("Hello world!");
            tv.setId(2);

                layout.addView(tv);

---- not any error in the console ----the sketch is launched "successfully" ---- the app crashes on the device (real one) ---- not any error message returned....

-----then i have tried to create manually and put some layout: :: but where ??? -----i have created a layout folder in res, given an hard coded id to the layout but when i want to inflate it (in another fragment) i get an error saying that this resource does not exist

P3 eating my hard disk....

$
0
0

working with P3 && launching an app i got a weird error message "no space left on the device" i firstly thought that it was the phone, but it was not i saw at this time that on my hard disk very little space was left but i have normally a lot of space on this disk and i have not added nothing to it, only working with P3 that i suspected to add files and files. I looked at these files, which are temp files:: and found that i have 15Go created in these subfolders... I deleted them of course and now my disk is as it was. BUT i think that adding some method to destroy these temp files is mandatory!!!

why same methods work Eclipse (+processingP3) and not in P3

$
0
0

the simplest example is::

Eclipse::

              @  Override
                    public void onAttach(Activity activity) {
                        super.onAttach(activity);
                        println("I am now in on attach life cycle");
                        act = super.getActivity();
                          c = act.getApplicationContext();
                          DisplayMetrics metrics = new DisplayMetrics();
                          act.getWindowManager().getDefaultDisplay().getMetrics(metrics);
                         println( metrics.widthPixels);
            }

returns== what is expected= myDisplay.width== some size

P3:error=== on attach() does not exists... and getWindowManager does not exist... and.... (....super has to be transformed in "getActivity()", but here it does not matter...)

Why???

so :: on create(), or on createdView() or on start()

exists:: Why??? not error.... returns nothing...

there is obviously something i have not understood: is the aim (P3, android mode) to make simpler things that are not so simple (though!!) with android or make these simple things impossible??? on attach() is not called??? what is the use for android imports if they are ignored???

thanks in advance because now i begin to be tired out by P3 android mode....

Individual color of CP5 dropdownlist items

$
0
0

I had a game where i used a dropdownlist to show the color of each player.

I used this loop to give each dropdownlist item a different color (where the playerList.get(i).farve variable is a color and PlayerDDsets is the dropDownList)

for (int i = 0; i<playerList.size (); i++) { PlayerDDsets.getItem(i).setColorBackground(playerList.get(i).farve); }

After updating to processing 3.0 i get the error "The fiunction setColorBackground(int) does not exist.

I can not use an earlier revision of processing because i need android mode

Viewing all 941 articles
Browse latest View live