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

I'd like to have simple AlertDialog in my Processing-Android sketch

$
0
0

Hi,

I'd like to have simple AlertDialog window with OK confirm button in my processing sketch for Android target...

I've found example code here : http://forum.processing.org/one/topic/android-pop-up-windows#25080000001725349.html

but it doesn't work. It seems that fix is not that hard but is beyond my newbie knowledge in Android field... There is a hint how to solve this but I don't know how to use it (it's commented)...

My code :

//Import required classes
import android.app.AlertDialog;
import android.content.DialogInterface;
//    Activity activity;

void setup() {

//    activity=(Activity) this.context;
//    activity.runOnUiThread(Runnable r) ;

//Create the AlertDialog
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
//Set the title
alertDialog.setTitle("Alert");
//Set the message
alertDialog.setMessage("This is an AlertDialog!");
//Add the OK button
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
  public void onClick(DialogInterface dialog, int which) {
    //The OK button has been clicked
 }});
//Display the AlertDialog
alertDialog.show();
}

void draw() {
}

I get this error :

FATAL EXCEPTION: Animation Thread java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() at android.os.Handler.(Handler.java:121) at android.app.Dialog.(Dialog.java:101) at android.app.AlertDialog.(AlertDialog.java:67) at android.app.AlertDialog$Builder.create(AlertDialog.java:800) at processing.test.popup_test.popup_test.setup(popup_test.java:35) 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:1019)

Would kindly ask for example code that works or any other help or pointer...

Thanks in advance, regards, Bulek.


Viewing all articles
Browse latest Browse all 941

Trending Articles