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

FATAL EXCEPTION: GLThread error. "The pixels array is not available in this renderer..."

$
0
0

I get this error on compile, any idea how to fix? I'm using the P3D renderer, but I get the same error with P2D, or the default renderer. "The pixels array is not available in this renderer withouth a backing bitmap" error regardless of which renderer I use. Also, they spelled without wrong.

FATAL EXCEPTION: GLThread 42277
Process: processing.test.myapp, PID: 18315
java.lang.RuntimeException: The pixels array is not available in this renderer withouth a backing bitmap
    at processing.a2d.PGraphicsAndroid2D.updatePixels(Unknown Source)
    at processing.test.myapp.myapp.fadeGraphics(myapp.java:624)
    at processing.test.myapp.myapp.draw(myapp.java:291)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.opengl.PSurfaceGLES$RendererGLES.onDrawFrame(Unknown Source)
    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1583)
    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1286)

Processing to Android visualization on Android

$
0
0

I am running Processing Sketches on Android Studio. Did it through exporting the project from Processing to Android, checking all the libraries. Then started a new Android Project, added these libraries, and that's it.. Now the question is how to project them in a visually appealing way on the activity layout.. For instance, how can I control how big the area is a Processing Sketch is displayed on. Another question is how to load a number of Processing Sketches in different places on the Layout.

Does anyone have experience on this, can share some code, point me to some sketches...?

THANKS!!!!

public class MainActivity extends AppCompatActivity {  

private PApplet sketch;
private PApplet secondsketch;

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FrameLayout frame = new FrameLayout(this);
    frame.setId(CompatUtils.getUniqueViewId());
    setContentView(frame, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));


    sketch = new weatherBrussels();

    PFragment fragment = new PFragment(sketch);
    fragment.setView(frame, this);
}


public void onRequestPermissionsResult(int requestCode,
                                       String permissions[],
                                       int[] grantResults) {
    if (sketch != null) {
        sketch.onRequestPermissionsResult(requestCode, permissions, grantResults);
    }
}


public void onNewIntent(Intent intent) {
    if (sketch != null) {
        sketch.onNewIntent(intent);
    }
}

}

Sound library for synthesis and audio playback and beat detection.

$
0
0

I'm currently using minim library. Someone uploaded a "minim for android" (https://github.com/DASAR/Minim-Android) project on github but I can't for the life of me figure out how to get it to work so I need an alternative.

Currently I'm using minim to synth audio. Specifically I'm using sin wave function, as well as a brown noise generator and band pass filter, as well as beat detection and music for a background track. Is there any other ways I can do this easily?

java.lang.Out OfMemoryError. Failed to allocate a 8294412 byte allocation with 7320368 free bytes

$
0
0

java.lang.Out OfMemoryError. Failed to allocate a 8294412 byte allocation with 7320368 free bytes and 6MB until OOM.

I'm only using 1 actual picture in the app. Do generated PImages take a lot of memory or something? My app runs at 1fps when it even works. Are pixel array edits feasible on mobile or is it fundamentally too slow? My app only has 5 PImages and 3 PGraphics elements. 1 of the Pimages is a .png file.

How to load and save table on android without error "File contains a path separator"?

$
0
0

Hey! I'm trying to develop an app on android with processing that needs to save information in a table for next time use and then retrieve it later on. (Sort of like a leaderboard record). The problem is that saveTable() and loadTable() don't work because the error java.lang.IllegalArgumentException: File contains a path separator is returned. Here is bascially what I'm trying to do (Which works fine on normal PC): In setup:

try { PersonalDetails = loadTable("AccountInfo.csv", "header"); // PersonalDetails is my table variable. if (PersonalDetails.getRowCount() > 0) { Registered = true; LocalScore = PersonalDetails.getRow(0).getInt("Score"); } } catch (NullPointerException e) { Table createCSV = new Table(); createCSV.addColumn("ID", Table.INT); createCSV.addColumn("Score", Table.INT); createCSV.addColumn("Name", Table.STRING); saveTable(createCSV, "data/AccountInfo.csv"); PersonalDetails = loadTable("AccountInfo.csv", "header"); if (PersonalDetails.getRowCount() > 0) { Registered = true; LocalScore = PersonalDetails.getRow(0).getInt("Score"); } }

And then in draw basically continuously save as score updates:

void draw() { if (Start) { if (Registered) { PersonalDetails.setInt(0, "Score", LocalScore); saveTable(PersonalDetails, "data/AccountInfo.csv"); } } background(255); }

As for android I continued to get the error stated above. I've tried multiple solutions to try to fix this including an InputStream and BufferedReader, this read the file perfectly fine:

BufferedReader br; String line; void readInfo() { try { InputStream is = createInput("AccountInfo.txt"); br = new BufferedReader(new InputStreamReader(is, "UTF-8")); while ((line=br.readLine())!=null) { System.out.println(line); } } catch (IOException e) { System.out.println("IOException when trying to read AccountInfo.txt:\n"+e); System.exit(0); } }

But, every approach i've taken so far to try to write the file failed. I'm assuming read works better because it will auto search the /files/ directory when not specified with a path. So far i've tried to use a BufferedWriter and PrintWriter in the same way as readInfo() above, hoping it would work, but it didn't:

PrintWriter saveInformation; BufferedWriter writer = null; void saveInfo() { try { writer = new BufferedWriter(new FileWriter("accountinfo.csv")); saveInformation = new PrintWriter("accountinfo.csv"); saveInformation.println("Changed Text File..."); writer.write("Changed Text file..."); } catch ( IOException e) { } finally { try { if ( writer != null ) writer.close( ); if (saveInformation != null) saveInformation.close(); } catch ( IOException e) { } } }

I have also tried to use the AssetManager, couldn't get that working. Also, I tried to use all above listed methods with relative file path and absolute file path. Each of these would similarly return the same error "java.lang.IllegalArgumentException: File contains a path separator".

Any help or feedback on the matter would be immensely very much greatly incredibly much appreciated!

Showing Visualizations in Particular Positions in Android Studio

$
0
0

I am developing an Application in Android. For the visualization part, I am using Processing. Now I would like to show a number of visualization on one Android Activity.

The standard code for one visualization is the following:

public class MainActivity extends AppCompatActivity {
  private PApplet sketch;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FrameLayout frame = new FrameLayout(this);
    frame.setId(CompatUtils.getUniqueViewId());
    setContentView(frame, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                                                     ViewGroup.LayoutParams.MATCH_PARENT));

    sketch = new Sketch();
    PFragment fragment = new PFragment(sketch);
    fragment.setView(frame, this);
  }

The code found on the "Processing for Android" website works for a single visualization. Now I would like to extend this to a number of visualizations each given a specific (x,y) position on the Activity Layout. Which methods allow me to do that?

Can you point me in the right direction?

Kind regards,

Niels

Use an AsyncTask to load PImages

$
0
0

Hi

Working in Android Studio with Processing for Android, I'm trying help the start of my app by having the loading of images transferred to a parallel thread

It seem an AsyncTask class is the way to go and I found a good reference to see how it is done The thing is, instead of 'Bitmap' and 'ImageView' I'm here working with PImage

Any idea on how to turn this Class

class BitmapWorkerTask extends AsyncTask<Integer, Void, Bitmap> {
    private final WeakReference<ImageView> imageViewReference;
    private int data = 0;

    public BitmapWorkerTask(ImageView imageView) {
        // Use a WeakReference to ensure the ImageView can be garbage collected
        imageViewReference = new WeakReference<ImageView>(imageView);
    }

    // Decode image in background.
    @ Override
    protected Bitmap doInBackground(Integer... params) {
        data = params[0];
        return decodeSampledBitmapFromResource(getResources(), data, 100, 100));
    }

    // Once complete, see if ImageView is still around and set bitmap.
    @ Override
    protected void onPostExecute(Bitmap bitmap) {
        if (imageViewReference != null && bitmap != null) {
            final ImageView imageView = imageViewReference.get();
            if (imageView != null) {
                imageView.setImageBitmap(bitmap);
            }
        }
    }
}

and this code

public void loadBitmap(int resId, ImageView imageView) {
    BitmapWorkerTask task = new BitmapWorkerTask(imageView);
    task.execute(resId);
}

into something that would work for PImage ?

tint() PImage Android Mode

$
0
0

Hi.

Code below does exactly what I want; fading picture into almost white. However it does fade always in Java mode it does not in Android mode, better to say I've only one image that does fade in Android mode. I've checked if the pictures have an alpha channel with GIMP and they do. How to generate images that will fade? This is driving me nuts. You can download my fading image here.

Any rescue?

(int i = 255;
boolean flag1;
PImage img;

void setup() {
  size (600, 600);
  background(255);
  img = loadImage("uyf.png");
  tint(255, 255); 
  image(img, 0, 0);
}

void draw() {  
  if (flag1){
  background(255);
  tint(255, i); 
  image(img, 0, 0); 
  i -= 6;
  if(i < 40) flag1 = false;
  }
}

void mousePressed(){
  flag1 = true;
}
)

plotting data

$
0
0

Hello, I am a new one in programming and i would like your help.I want a code in processing i3 that could read a txt or csv file of data and make a real graph.Especcially to read ecg signals and make a cardiograph.Thanks a lot..

Android Mode - Serial Communication - Andruino

$
0
0

Hi, nice to meet you.

I want (Arduino) ------- (Smartphone) Serial connection.

Processing 3.2.1. Android Mode 3.0.1

> API 6.0

======================================================================

import io.inventit.processing.android.serial.*; //ANDROID

Serial myPort;      
String inString=""; 

void setup() {

  myPort = new Serial(this, Serial.list(this)[0], 38400); 
  myPort.bufferUntil(10);
}

//===========INCOMING DATA FROM THERMOSTAT=============
void serialEvent(Serial myPort) { 


  try {
    inString = myPort.readString();

  }
  catch(RuntimeException e) {

  }


}

====================================================================== **Error msg : **

Processing - Android USB Serial Error.

Q

Not able to run the code in android mode, i have put up the code and the error.

$
0
0

Not able to run the code in android mode, anyone familiar with error, please help.

This is the code: `import beads.*; import java.util.List;

AudioContext ac; WavePlayer wp; Gain g; Glide gainGlide; Glide frequencyGlide;

void setup() { ac = new AudioContext();

gainGlide = new Glide(ac, 40f, 20); frequencyGlide = new Glide(ac, 250, 20); wp = new WavePlayer(ac, frequencyGlide, Buffer.SINE); g = new Gain(ac, 1, gainGlide); g.addInput(wp); ac.out.addInput(g); ac.start(); }`

This is the error: AudioContext : no AudioIO specified, using default => beads.JavaSoundAudioIO. FATAL EXCEPTION: Thread-20174 Process: processing.test.sketch_180311a, PID: 11871 java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/sound/sampled/AudioFormat; at beads.JavaSoundAudioIO.create(Unknown Source) at beads.JavaSoundAudioIO$1.run(Unknown Source) at java.lang.Thread.run(Thread.java:818) Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.sound.sampled.AudioFormat" on path: DexPathList[[zip file "/data/app/processing.test.sketch_180311a-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) ... 3 more Suppressed: java.lang.ClassNotFoundException: javax.sound.sampled.AudioFormat at java.lang.Class.classForName(Native Method) at java.lang.BootClassLoader.findClass(ClassLoader.java:781) at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at java.lang.ClassLoader.loadClass(ClassLoader.java:504) ... 4 more Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

Zoom with two fingers

$
0
0

Could you please provide me an example code in processing i3 that i can make zoom with two fingers in my App,in Android Mode??I would like to zoom in the whole screen, not only in a shape..

[Solved] Building the basic app example faild with this error

$
0
0

Solved it by installing updates suggested by android studio Hi, I just tried to build the basic example in http://android.processing.org/tutorials/getting_started/index.html processing version : 3.3.6 installed Android studio 3.0.1 and its Sdk . I tried building a project with Apache Cordova and ionic and it works. but processing does not ! it failed with the following error :

Build folder: /tmp/android129914558782287586sketch Warning: cannot find AAR package wearable-2.0.5.aar in installed SDK, gradle will try to download. NDK is missing a "platforms" directory. If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to /home/bahha/Android/Sdk/ndk-bundle. If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

:app:preBuild UP-TO-DATE :app:preDebugBuild FAILED

FAILURE: Build failed with an exception.

BUILD FAILED in 10s 1 actionable task: 1 executed org.gradle.tooling.BuildException: Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-4.4.1-bin.zip'. at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:51) at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:29) at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:41) at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57) 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.exceptions.LocationAwareException: Could not resolve all files for configuration ':app:debugCompileClasspath'.

File list files in directory

$
0
0

Hi. I've tried several code snippets to get the file names of a specific directory, but all gave me a null. What would be the correct way? Thanks in advance.

import java.io.File;
import android.os.Environment;

// String path = Environment.getExternalStorageDirectory().toString()+"/Download";
 String path = "/storage/emulated/legacy/Download"; 

 File f = new File(path); 
 File[] files = f.listFiles();
 printArray(files);

Converting File[] to ArrayList

$
0
0

Hi, I've tested in several ways this conversion and the most logical way, seems to me would be by iterating, but it gives the error:

The method add(String) in the type ArrayList is not applicable for the arguments (File)

How to do this, thanks.

ArrayList<String> alfiles = new ArrayList<String>();
File[] files = f.listFiles();
for (File each : files) alfiles.add(each);

Cannot install Android mode

$
0
0

When I try to install Android Mode from within Processing I get the message "Could not find a mode in the downloaded file" in the Mode Manager window. However, the other modes could be installed without problem.

I've also tried to download the Android Mode manually to the modes folder, but it never gets recognized and included in the mode popup.

Processing 2.2.1, OS X 10.9.4.

Did anyone else have the same problem?

android-mode-install-error

android-mode

Google Reviews Over 50 Billion Android Apps Daily

$
0
0

lay Protect, the security service that arrived on Android last year, reviews more than 50 billion apps each day, Google claims.

Launched in May 2017, Google Play Protect brings together various security services for Android, many of which have been available for years, but without being as visible as they are now. Mainly designed to protect users from Potentially Harmful Apps (PHAs), it reviews not only billions of apps, but other potential sources of PHAs as well and user devices, to take action when necessary.

Play Protect was designed to automatically check Android devices for PHAs at least once a day, and also provides users with the possibility to conduct additional reviews at any time. Because of these daily checks, nearly 39 million PHAs were removed last year, the Internet giant reveals.

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?

KetaiList

$
0
0

Hi. I copied the KetaiList class into a new processing tab to be able to customize it. But I only managed to change the backGround color. I tried to set textColor and do some padding, but although it doesn't give any errors, it also hasn't any effect. Any idea what is wrong? Thanks in advance

import java.lang.reflect.Method;
import java.util.ArrayList; 
import processing.core.PApplet;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView; 

// void onKetaiListSelection(String selection) - selection is the string * selected from the list

public class KetaiList extends ListView { 

  private PApplet parent; 
  private ArrayAdapter<String> adapter; 
  String name = "KetaiList"; 
  String selection = "";
  ListView self; 
  RelativeLayout layout; 
  private Method parentCallback; 
  String title = "";
  public KetaiList(PApplet _parent, ArrayList<String> data) {       
    super(_parent.getActivity().getApplicationContext());       
    parent = _parent;       
    adapter = new ArrayAdapter<String>(parent.getActivity(), android.R.layout.simple_list_item_1, data);        
    init();
  } 
  public KetaiList(PApplet _parent, String[] data) {        
    super(_parent.getActivity().getApplicationContext());       
    parent = _parent;       
    adapter = new ArrayAdapter<String>(parent.getActivity(), android.R.layout.simple_list_item_1, data);        
    init();
  }
  public KetaiList(PApplet _parent, String _title, String[] data) {     
    super(_parent.getActivity().getApplicationContext());       
    parent = _parent;       
    title = _title;     
    adapter = new ArrayAdapter<String>(parent.getActivity(), android.R.layout.simple_list_item_1, data);        
    init();
  } 
  public KetaiList(PApplet _parent, String _title, ArrayList<String> data) {        
    super(_parent.getActivity().getApplicationContext());       
    parent = _parent;       
    title = _title;     
    adapter = new ArrayAdapter<String>(parent.getActivity(), android.R.layout.simple_list_item_1, data);        
    init();
  } 
  public void refresh() {       
    if (adapter == null)            return;     
    parent.getActivity().runOnUiThread(new Runnable() {         
      public void run() {               
        adapter.notifyDataSetChanged();
      }
    }
    );
  } 
  public String getSelection() {        
    return selection;
  }
  private void init() {     
    setBackgroundColor(Color.BLUE);     
  //  setTextColor(Color.BLACK);
    setAlpha(1);        
    self = this;        
    layout = new RelativeLayout(parent.getActivity());      

    if (title != "") {          
      TextView tv = new TextView(parent.getActivity());
   //   tv.setPadding(100,100,0,0);
      tv.setText(title);            
   //   tv.setTextColor(Color.parseColor("#bdbdbd"));
      setHeaderDividersEnabled(true);           
      addHeaderView(tv);
    }       
    try {           
      parentCallback = parent.getClass().getMethod("onKetaiListSelection", new Class[] { KetaiList.class });            
      PApplet.println("Found onKetaiListSelection...");
    } 
    catch (NoSuchMethodException e) {
    }       
    setAdapter(adapter);        
    setOnItemClickListener(new OnItemClickListener() {          
      public void onItemClick(AdapterView<?> p, View view, int position, long id) {                 
        selection = adapter.getItem(position).toString();               
        layout.removeAllViewsInLayout();                
        try {                   
          parentCallback.invoke(parent, new Object[] { self });
        } 
        catch (Exception ex) {
        }               
        self.setVisibility(View.GONE);              
        ((ViewManager) self.getParent()).removeView(self);              
        parent.getActivity().runOnUiThread(new Runnable() {                 
          public void run() {                       
            layout.removeAllViews();                        
            layout.setVisibility(View.GONE);
          }
        }
        );
      }
    }
    ); 
    parent.getActivity().runOnUiThread(new Runnable() {         
      @SuppressWarnings("deprecation")      
        public void run() {             
        parent.getActivity().addContentView(self, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
      }
    }
    );
  }
}

Please, Android Mode. How to display notification messages on smartphone

$
0
0

[How to display notification messages on smartphone] 1) Event a0

2) Message a1

3) Application action a2

(Video Link : image)

How can I do that?

How can I make a message appear when I turn off my app?

Please help me.

Viewing all 941 articles
Browse latest View live