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

Connecting VR and Ketai Bluetooth in Android mode

$
0
0

Hi all,

I am having problems connecting VR mode and Ketai Bluetooth connectivity in Android mode. (Win10; Porcessing 3.3.5; Android 6.0.1; Samsung S5 Neo). Independently code for Ketai bluetooth works:

import processing.vr.*;
import android.content.Intent;
import android.os.Bundle;
import ketai.net.bluetooth.*;
import ketai.ui.*;
//import ketai.net.*;

PFont fontMy;
KetaiBluetooth bt;
String info = "";

//********************************************************************
// The following code is required to enable bluetooth at startup.
//********************************************************************

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

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

//********************************************************************

void setup() {
  //fullScreen(STEREO);
  size(displayWidth, displayHeight, P3D);
  //start listening for BT connections and connect to a device.
  bt.start();
  bt.connectDevice("00:14:03:06:37:0E");
  //font size
  fontMy = createFont("SansSerif", 40);
  textFont(fontMy);
}

void calculate() {
}

void draw() {
  background(150);
  translate(width/2, height/2);
  noStroke();
  // Green box, Y axis
  pushMatrix();
  translate(0, 200, 0);
  fill(0, 255, 0);
  box(100);
  popMatrix();
  // text from Bluetooth
 // info = "abc\ndef"; //debugging
  text(info, 20, 104);
}

void onBluetoothDataEvent(String who, byte[] data) {
  //received
  info = new String(data);
}

Everything connects nicely to my HC-05 and gets the info, and prints it next to the green box. But then I decide to add VR functionality, and everything goes wrong. So I un-comment //fullScreen(STEREO); and comment
size(displayWidth, displayHeight, P3D);, and change Android mode from "App" to "VR". The build is successful, but the app crashes and I get the following error:

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean ketai.net.bluetooth.KetaiBluetooth.start()' on a null object reference at processing.test.test2.test2.setup(test2.java:63) at processing.core.PApplet.handleDraw(Unknown Source) at processing.vr.PSurfaceVR$AndroidVRStereoRenderer.onDrawEye(Unknown Source) at com.google.vr.sdk.base.CardboardViewNativeImpl.nativeOnDrawFrame(Native Method) at com.google.vr.sdk.base.CardboardViewNativeImpl.access$2500(CardboardViewNativeImpl.java:53) at com.google.vr.sdk.base.CardboardViewNativeImpl$RendererHelper.onDrawFrame(CardboardViewNativeImpl.java:569) at com.google.vr.ndk.base.GvrSurfaceView$GLThread.guardedRun(GvrSurfaceView.java:1643) at com.google.vr.ndk.base.GvrSurfaceView$GLThread.run(GvrSurfaceView.java:1324) handleDraw() called before finishing

The VR-code will work nicely, if I comment the bt.start();and bt.connectDevice("00:14:03:06:37:0E");

Is it normal? Can Ketai work with In-built Processing Arduino VR Mode at all?

Thanks!


Android Input Box

$
0
0

Hi. I am trying to code an android Input Box. The G4P lib uses libs that are not available on android. I did manage to write a working code in plain Processing code, but the "key" keyword doesn't read coded keys like BACKSPACE and other characters like 'á'. on my device. Then I found a really nice code of @akenaton here , and with the kind help of @olivi55 who teached me how to edit the TextField, I wrote an example code for an InputBox. I now need to figure out how to hide the textbox as soon as I enter the End key.( Enter) , how to link that. In code below it will hide the keyboard., but not the textbox. The textbox will hide and write the input string on the screen only after I hit the input button.

CODE:

import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import android.widget.LinearLayout;
import android.text.Editable;
import android.graphics.Color;
import android.widget.EditText;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.view.View;
import android.widget.TextView;
import android.view.ViewGroup;
import android.view.ViewParent;

EditText edit;
Activity act;
Context mC;
FrameLayout fl;
boolean bflag = true;
String txt;
int flag = 1, xbut, ybut, wbut = 110, hbut = 35;

@Override
  public void onStart() {
    super.onStart();
    act = this.getActivity();
    mC= act.getApplicationContext();
    act.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
    edit = new EditText(mC);
    edit.setLayoutParams (
      new RelativeLayout.LayoutParams (
        RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT
      )
    );
    edit.setHint("Write Here!");
    edit.setTextColor(Color.rgb(0, 0, 0));
    edit.setHintTextColor(Color.rgb(170, 170, 170));
    edit.setBackgroundColor(Color.WHITE);      // edit.getBackground().setAlpha(255);
    fl = (FrameLayout)act.findViewById(0x1000);
    edit.getLayoutParams().width=14*width/26;
    edit.getLayoutParams().height=height/17;
    edit.setX(width/3);
    edit.setY(height/6);
    edit.requestFocus();
    edit.setInputType(android.text.InputType.TYPE_CLASS_TEXT);
    fl.addView(edit);
  }

void setup() {
  fullScreen();
  orientation(LANDSCAPE);
  background(0, 0, 255);
  xbut = width/10;
  ybut = height/6;
  inputButton(xbut, ybut, wbut, hbut);
}

void draw() {
  if (flag == 1) {
    showInputBox();
    flag = 3;
  }
  if (flag == 2) {
    hideInputBox();
    flag = 3;
  }
}

void showInputBox() {
  background(0, 0, 255);
  String txt = edit.getText().toString();
  edit.getText().clear();
  text("Please type some input.", width/3, height/12);
  inputButton(xbut, ybut, wbut, hbut);
  act.runOnUiThread(
    new Runnable() {
      public void run() {
        edit.setVisibility(View.VISIBLE);
        edit.requestFocus();
      }
    }
  );
}

  public void onResume() {
    super.onResume();
      act.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
  }


void hideInputBox() {
  background(0, 0, 255);
  inputButton(xbut, ybut, wbut, hbut);
  String txt = edit.getText().toString();
  text("Your input was:  " + txt, width/3, height/12);
  act.runOnUiThread(
    new Runnable() {
      public void run() {
        edit.setVisibility(View.GONE);
      }
    }
  );
}

void mousePressed() {
  if (mouseX >= xbut && mouseX <= xbut + wbut &&  mouseY >= ybut && mouseY <= ybut + hbut) {
    if (bflag) {
      flag = 2;
      bflag = false;
    } else {
      flag = 1;
      bflag = true;
    }
  }
}

void inputButton (int x, int y, float w, float h) {
  textSize(20);
  stroke(127);
  rect(x, y, w, h);
  color c2 = color(130, 0, 0);
  color c1 = color(255, 85, 0);
  for (int i = y; i <= y+h; i++) {
    float inter = map(i, y, y+h, 0, 1);
    color c = lerpColor(c1, c2, inter);
    stroke(c);
    line(x, i, x+w, i);
  }
  fill(255);
  text("Input", x + 30, y + 25);
}

I loaded the AIDE App, to learn Java. but I don't want to lett Processing down because I love it for my artwork and arduino projects. I really would appreciate some help. Emmanuel

troubles while trying to export a signed package

$
0
0

Hi everyone, as the title says i can't export a signed package. The first time i had to chage the package name (inside of the AndroidManifiest.xml) which was easy to solve (just add the name) then, i had to add the icons of the app, which i did, but it keeps showing me the following "warning":

Screenshot_1

but i added them in the sketch folder like this:

Screenshot_2

any idea on which is the problem?

First time exporting signed package

$
0
0

Hi everyone, this time i'm having a new trouble. When i try to export a package, the console trhows the following output:

C:\Users\Erwrow\AppData\Local\Temp\android8460647747353924441sketch\app\build.gradle: Error: Project depends on com.google.android.support:wearable:2.0.5, so it must also depend (as a provided dependency) on com.google.android.wearable:wearable:2.0.5 [GradleCompatible]

Explanation for issues of type "GradleCompatible": There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion.)

1 errors, 0 warnings

then generates the .apk file but it seems "damaged" and don't install. What am i doing wrong?

How do a get image files on to my android?

$
0
0

Howdy, I'm new to processing and new to Androi so I suspect i have a conceptual block here. I've written a very simple routine that is trying to load a background image. Code Follows. It runs fine in Java but when I try to run it on the Android Emulator I'm getting a

java.io.FileNotFoundException: /data/user/0/processing.test.wrapmate/files/bg.jpg (No such file or directory)

I'm assuming this is because my image file is sitting on my computer and not on my Device (either a real one or the Emulator).

So a) during development, what's the way to get any image files I need to access to the right place on the Android so that the program can access them?

b) If I eventually want to "deploy" an app to my friend's devices (like through the App Store?) how do I ensure that any image files come along with the application?

Thanks!

Dave

edit... trying to learn to format code in the forum. Sorry!

void setup()
{
  size(displayWidth, displayHeight, P3D);
}

void draw()
{
  //noStroke();
  PImage back;
  back = loadImage("bg.jpg");
  back.resize (displayWidth, displayHeight);
  background(back);

  float box_width = 60;

  if (mousePressed) {
    box_width = mouseX;
  }

  lights();
  translate(width/2, height/2, 0);
  rotateX(-PI/6);
  rotateY(PI/2 + 210/float(height) * PI);
  box(box_width, displayHeight/6, displayWidth/3);
}

Root access on processing?

$
0
0

Hi ! I'm searching a way to grant root access for my processing app (to write on system file). Is it possible?

Google Play Add Icon Daydream in Manifest

$
0
0

Google play told me that I have to add an icon daydream into my manifest? How can I do it?

VR menu Options not available

$
0
0

My process of Installation.

Download Processing 3.3.4-Windows64

Extract to a folder within User Directory

I did not AutoDownload the SDK, I had an SDK forder and specified directory.

SDK is outside of User Directory but still within access.

Added Android Mode 3.0.2

Update/Install Several packages in Android SDK package manager

Tested that an app can be made in processing and tested on phone using Getting Started.

http://android.processing.org/tutorials/getting_started/index.html

Downloaded AndroidMode4.0 beta3

https://github.com/processing/processing-android/releases/tag/android-262

Moved AndroidMode to modes of the processing directory after extracting Android-262.

Before Copy, only Java folder was available in the Modes directory.

Closed Processing, and opened again.

In android mode, on the Androids tab, everything that should be there, except for the app, wallpaper, watch face and Cardboard/VR.

I do not know what I am missing to get the VR option available in the menu. Any help is appreciated.


Navigating a 3D space in VR

$
0
0

Hello everyone!

I'm new to the Android mode and I'm trying to build a little app to navigate a 3D model of a city. I haven't started writing the code yet, as I was exploring the examples in order to understand what can be done. However, I've seen the sketches respond solely to head movement and not to walking forward or backward. Is there any way to do this? So the user can 'walk' around and navigate the 3D model?

CP5 Slider: Android Issue

$
0
0

Hello, i'd like to use Control P5 Sliders in an android-project. But unfortunately, the sliders behave different than in Java mode. On the Android-phone, you have to click one slider twice to change the value. This is bad, because the first click can affect the state of the slider which was selected before. Any idea how to solve this problem? Thanks!

import controlP5.*;

ControlP5 cp5;

void setup(){
  fullScreen();
  cp5 = new ControlP5(this);

  cp5.addSlider("ONE")
  .setPosition(50,100)
  .setSize(width-100, 50);

  cp5.addSlider("TWO")
  .setPosition(50,200)
  .setSize(width-100, 50);
}

void draw(){
}

How to get standalone Android SDK

$
0
0

Hello there, i'm writing a tutorial for Android development with processing. Under Windows 10, it seems to be quite awkward to get the SDK. ("Automatic Download" does not work, interrupts after some 100 MB...). Ok, is there another way to get the SDK but installing Android Studio, opening the SDK manager etc? A direct Download would be fantastic. Any idea? Thanks!

Gradle error in android mode

$
0
0

Hello everybody,

i'm a system administrator in a school and i work with a teacher who wants to use processing with android mode. So, i'm trying to make it works but i have a problem when i try to run on device any example found in processing. This problem appears with all example i tried. I installed gradle on my windows10 and configured the path as i saw on the gradle website. Anybody can help me please ? Thanks (i paste the error in processing) :

Build folder: C:\Users\locadm\AppData\Local\Temp\android6707999252373326126sketch org.gradle.tooling.GradleConnectionException: Could not create an instance of Tooling API implementation using the specified Gradle distribution 'https://services.gradle.org/distributions/gradle-4.4.1-bin.zip'. at org.gradle.tooling.internal.consumer.loader.DefaultToolingImplementationLoader.create(DefaultToolingImplementationLoader.java:110) at org.gradle.tooling.internal.consumer.loader.CachingToolingImplementationLoader.create(CachingToolingImplementationLoader.java:44) at org.gradle.tooling.internal.consumer.loader.SynchronizedToolingImplementationLoader.create(SynchronizedToolingImplementationLoader.java:43) at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.onStartAction(LazyConsumerActionExecutor.java:101) at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.run(LazyConsumerActionExecutor.java:83) at org.gradle.tooling.internal.consumer.connection.CancellableConsumerActionExecutor.run(CancellableConsumerActionExecutor.java:45) at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConsumerActionExecutor.run(ProgressLoggingConsumerActionExecutor.java:58) at org.gradle.tooling.internal.consumer.connection.RethrowingErrorsConsumerActionExecutor.run(RethrowingErrorsConsumerActionExecutor.java:38) at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:55) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) at java.lang.Thread.run(Thread.java:748) at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46) at org.gradle.tooling.internal.consumer.DefaultBuildLauncher.run(DefaultBuildLauncher.java:77) at processing.mode.android.AndroidBuild.gradleBuild(AndroidBuild.java:287) at processing.mode.android.AndroidBuild.build(AndroidBuild.java:231) at processing.mode.android.AndroidMode.handleRunDevice(AndroidMode.java:315) at processing.mode.android.AndroidEditor$15.run(AndroidEditor.java:373) Caused by: org.gradle.internal.service.ServiceLookupException: Could not configure services using ConnectionScopeServices.configure(). at org.gradle.internal.service.DefaultServiceRegistry.applyConfigureMethod(DefaultServiceRegistry.java:205) at org.gradle.internal.service.DefaultServiceRegistry.findProviderMethods(DefaultServiceRegistry.java:180) at org.gradle.internal.service.DefaultServiceRegistry.addProvider(DefaultServiceRegistry.java:255) at org.gradle.internal.service.ServiceRegistryBuilder.build(ServiceRegistryBuilder.java:52) at org.gradle.tooling.internal.provider.DefaultConnection.initializeServices(DefaultConnection.java:119) at org.gradle.tooling.internal.provider.DefaultConnection.configure(DefaultConnection.java:102) at org.gradle.tooling.internal.consumer.connection.AbstractPost12ConsumerConnection.configure(AbstractPost12ConsumerConnection.java:37) at org.gradle.tooling.internal.consumer.loader.DefaultToolingImplementationLoader.createConnection(DefaultToolingImplementationLoader.java:115) at org.gradle.tooling.internal.consumer.loader.DefaultToolingImplementationLoader.create(DefaultToolingImplementationLoader.java:91) at org.gradle.tooling.internal.consumer.loader.CachingToolingImplementationLoader.create(CachingToolingImplementationLoader.java:44) at org.gradle.tooling.internal.consumer.loader.SynchronizedToolingImplementationLoader.create(SynchronizedToolingImplementationLoader.java:43) at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.onStartAction(LazyConsumerActionExecutor.java:101) at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.run(LazyConsumerActionExecutor.java:83) at org.gradle.tooling.internal.consumer.connection.CancellableConsumerActionExecutor.run(CancellableConsumerActionExecutor.java:45) at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConsumerActionExecutor.run(ProgressLoggingConsumerActionExecutor.java:58) at org.gradle.tooling.internal.consumer.connection.RethrowingErrorsConsumerActionExecutor.run(RethrowingErrorsConsumerActionExecutor.java:38) at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:55) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) at java.lang.Thread.run(Thread.java:748) Caused by: org.gradle.internal.service.ServiceCreationException: Could not create service of type ModuleRegistry using GlobalScopeServices.createModuleRegistry(). at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.invokeMethod(DefaultServiceRegistry.java:797) at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.create(DefaultServiceRegistry.java:748) at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectProvider.getInstance(DefaultServiceRegistry.java:574) at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.get(DefaultServiceRegistry.java:623) at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.assembleParameters(DefaultServiceRegistry.java:761) at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.create(DefaultServiceRegistry.java:747) at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectProvider.getInstance(DefaultServiceRegistry.java:574) at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.get(DefaultServiceRegistry.java:623) at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.assembleParameters(DefaultServiceRegistry.java:761) at org.gradle.internal.service.DefaultServiceRegistry$FactoryService.create(DefaultServiceRegistry.java:747) at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectProvider.getInstance(DefaultServiceRegistry.java:574) at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.get(DefaultServiceRegistry.java:623) at org.gradle.internal.service.DefaultServiceRegistry.applyConfigureMethod(DefaultServiceRegistry.java:199) at org.gradle.internal.service.DefaultServiceRegistry.findProviderMethods(DefaultServiceRegistry.java:180) at org.gradle.internal.service.DefaultServiceRegistry.addProvider(DefaultServiceRegistry.java:255) at org.gradle.internal.service.DefaultServiceRegistry$1.addProvider(DefaultServiceRegistry.java:236) at org.gradle.tooling.internal.provider.ConnectionScopeServices.configure(ConnectionScopeServices.java:52) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73) at org.gradle.internal.service.ReflectionBasedServiceMethod.invoke(ReflectionBasedServiceMethod.java:35) at org.gradle.internal.service.DefaultServiceRegistry.applyConfigureMethod(DefaultServiceRegistry.java:203) ... 22 more Caused by: java.lang.IllegalArgumentException: URI has an authority component at java.io.File.(File.java:423) at org.gradle.internal.classloader.ClasspathUtil$1.visitClassPath(ClasspathUtil.java:64) at org.gradle.internal.classloader.ClassLoaderVisitor.visit(ClassLoaderVisitor.java:41) at org.gradle.internal.classloader.ClassLoaderVisitor.visitParent(ClassLoaderVisitor.java:82) at org.gradle.internal.classloader.ClassLoaderVisitor.visit(ClassLoaderVisitor.java:46) at org.gradle.internal.classloader.ClassLoaderVisitor.visitParent(ClassLoaderVisitor.java:82) at org.gradle.internal.classloader.ClassLoaderVisitor.visit(ClassLoaderVisitor.java:46) at org.gradle.internal.classloader.ClassLoaderVisitor.visitParent(ClassLoaderVisitor.java:82) at org.gradle.internal.classloader.ClassLoaderVisitor.visit(ClassLoaderVisitor.java:46) at org.gradle.internal.classloader.ClasspathUtil.getClasspath(ClasspathUtil.java:58) at org.gradle.api.internal.classpath.EffectiveClassPath.findAvailableClasspathFiles(EffectiveClassPath.java:36) at org.gradle.api.internal.classpath.EffectiveClassPath.(EffectiveClassPath.java:32) at org.gradle.api.internal.classpath.DefaultModuleRegistry.(DefaultModuleRegistry.java:62) at org.gradle.api.internal.classpath.DefaultModuleRegistry.(DefaultModuleRegistry.java:56) at org.gradle.internal.service.scopes.GlobalScopeServices.createModuleRegistry(GlobalScopeServices.java:186) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73) at org.gradle.internal.service.ReflectionBasedServiceMethod.invoke(ReflectionBasedServiceMethod.java:35) at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.invokeMethod(DefaultServiceRegistry.java:795) ... 45 more

how to access to the fingerprint sensor

$
0
0

since this is possible in android studio (at least i've found the permission "use_fingerprint") i would like to know if it's possible to access to the sensor with processing

Scrollable image with ScrollView

$
0
0

Hi. I want to scroll a large image horizontally, and the code below will do the job, but not as smooth that I'm used to, on my tablet (Samsung Tab E 9.6). It flickers a bit. Is there a way to improve it or better use java ScrollView containing an image?

PGraphics img;
int imgx;
boolean dragging = false;

void setup()  {
  fullScreen();
  orientation(LANDSCAPE);
  img = createGraphics(4 * width, height);
  img.beginDraw();
  img.fill(150);
  for (float i = 200; i <= 4 * width; i += 400) {
    img.ellipse(i, 400, 400, 400);
  }
  img.endDraw();
  frameRate(1000);
}

void draw() {
  background(255);
  imgx = constrain(imgx, -img.width + width, 0); 
  set(imgx, 0, img);
  if (!mousePressed && dragging) dragging = false;
  if (dragging) imgx += -pmouseX + mouseX;
}

void mousePressed() {
    dragging = true;
}

Run certain code only when in Android Mode

$
0
0

How do people run code that is only relevant when running on a phone?

For example I want my sketch look the same in Java and in Android mode. For this I have to use a strokeWeight that is proportional to displayDensity. Problem is the this variable is only available in Android mode. Similarly I only want to call size(width, height) in Java mode.

I can check for Android ...

if (System.getProperty("java.vendor") == "The Android Project") { strokeWeight(3*displayDensity) }

... but this will not compile because Java. In Javascript/Python this would just work because lazy evaluation and in C++ this could be done with #defines.

How do you do that in Processing/Java. Anybody knows a trick to make it work? Reflection module (looks crazy verbose)?

Let me know, Best,


Add Processing Core Library to Android Studio

$
0
0

Hello,

I have found a Tutorial for adding Processing Core Library to Android Studio. "http://android.processing.org/tutorials/android_studio/index.html"

It states that you need to add the "android-core.jar" to you dependencies in Android Studio. I have downloaded the .Zip file from the Processing GitHub account. In it, I have scrolled all the folders and files, cannot find the right .jar-file.

Where can I find the right .jar-file?

Kind regards

query about project android mode translation

$
0
0

I would like to know in details about the android mode translation project like a bit more details about possible outcomes and skills requirement because i am interested to contribute in it in gsoc 2018

Running Processing Sketches on Android

$
0
0

I have added "processing-android-core.jar" file to my Android Studio project. In order to run my Processing sketches on Android Studio I also need classes like "PFragment" and for my project "JSONObject". They are not included in the added "jar-file". It is quite hard to locate those files.

Can anyone point me to the right files?

Kind regards,

Niels

Not working emulator

$
0
0

I have problems running a sketch in Emulator (Android Mode) I use Processing 3.3.6 on Windows 10. Android Mode 4.0.1 installed.

  1. when I launch the emulator, I just get a black screen of Android Emulator - processing - phone:5566
  2. After a long wait with "Waiting for the emulator to become available" I get "Lost connection with emulator while launching. Try again".

It seems I have not accepted the license Agreement of the component [Android SDK Build - Tools 26.0.2]

Maybe there is a problem with the folder’s names…

Processing tells:

Checking the license for package Android SDK Build-Tools 26.0.2 in C:\Users\HP\Documents\Processing\android\sdk\licenses

but I have different folders' names (for instance, I have C:\Utenti\ ... that's the Italian for "Users"...

I just want to create very simple apps from simple Processing code. I fear my technical knowledge is … almost null; if you want to help me, you have to explain in detail what I have to do. Suggestions? Thanks a lot!

How to make the phone vibrate

$
0
0

Hello everyone,

I'm making a minesweeper game and when the player presses the mouse/finger down for long enough, you can place a marker. I want to make the phone vibrate when you have pressed down for long enough.

I searched on the internet quite a while and the only thing ive found is this code but i get the error: The variable "VIBRATOR_SERVICE" does not exist.

Can anyone please help me with this?

Here is my code:

import android.app.Activity; import android.content.Context; import android.os.Vibrator; import android.os.Build; void touchEnded() { if (Build.VERSION.SDK_INT >= 26) { ((Vibrator) getSystemService(VIBRATOR_SERVICE)).vibrate(VibrationEffect.createOneShot(150,10)); } else { ((Vibrator) getSystemService(VIBRATOR_SERVICE)).vibrate(150); } }

Viewing all 941 articles
Browse latest View live