Java mode, on the other hand, does not have the same functionality, although there is probably a library (not necessarily a Processing library) that will do the trick.
but i found error when application run on the screen here are errors
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
at android.os.Handler.<init>(Handler.java:205)
at android.os.Handler.<init>(Handler.java:119)
at android.widget.Toast$TN.<init>(Toast.java:339)
at android.widget.Toast.<init>(Toast.java:98)
at android.widget.Toast.makeText(Toast.java:245)
at processing.test.toast.toast.showToast(toast.java:40)
at processing.test.toast.toast.mousePressed(toast.java:36)
at processing.core.PApplet.mousePressed(Unknown Source)
at processing.core.PApplet.handleMouseEvent(Unknown Source)
at processing.core.PApplet.dequeueEvents(Unknown Source)
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)
FATAL EXCEPTION: Animation Thread
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
at android.os.Handler.<init>(Handler.java:205)
at android.os.Handler.<init>(Handler.java:119)
at android.widget.Toast$TN.<init>(Toast.java:339)
at android.widget.Toast.<init>(Toast.java:98)
at android.widget.Toast.makeText(Toast.java:245)
at processing.test.toast.toast.showToast(toast.java:40)
at processing.test.toast.toast.mousePressed(toast.java:36)
at processing.core.PApplet.mousePressed(Unknown Source)
at processing.core.PApplet.handleMouseEvent(Unknown Source)
at processing.core.PApplet.dequeueEvents(Unknown Source)
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)
1. ERROR in C:\Users\BPAS\AppData\Local\Temp\android4289731801464903815sketch\src\processing\test\notify\notify.java (at line 40)
runOnUiThread(new Runnable() {
^^^^^^^^^^^^^
The method runOnUiThread(new Runnable(){}) is undefined for the type notify
----------
2. ERROR in C:\Users\BPAS\AppData\Local\Temp\android4289731801464903815sketch\src\processing\test\notify\notify.java (at line 42)
android.widget.Toast.makeText(getApplicationContext(), message, android.widget.Toast.LENGTH_SHORT).show();
^^^^^^^^^^^^^^^^^^^^^
The method getApplicationContext() is undefined for the type new Runnable(){}
----------
2 problems (2 errors)
Answers
Toasts are built into Android - see the relevant API Guidelines. Something like this should do the trick:
Java mode, on the other hand, does not have the same functionality, although there is probably a library (not necessarily a Processing library) that will do the trick.
kindly tell me the name of the library plz
i run the code as an example here is my code
but i found error when application run on the screen here are errors
I don't know Android programming, but the error message seems explicit: "Can't create handler inside thread that has not called Looper.prepare()"
Oh, right. This code has to be run on the UI thread, like so:
thanks u calsign it works
calsign do tell me the library for showing message in java mode thanks in advance
@calsign Is it possible to launch a toast even when the app is closed. Sorry if i sound rubbish!
For the code
I get the following ERROR
PLEASE HELP!!!
@Aswinth_Raj===
@calsign===
you are not in an activity but in a fragment; so you have to write::
[-X
Thanks a lot guys!!
'import android.widget.Toast; import android.app.Activity;
Activity act;
void setup() { size(displayWidth,displayHeight); act = this.getActivity(); }
void draw() { background(255); }
void mousePressed() { showToast("Hellow World"); }
void showToast(final String message) { act.runOnUiThread(new Runnable() { public void run() { android.widget.Toast.makeText(act.getApplicationContext(), message, android.widget.Toast.LENGTH_SHORT).show(); } }); } '
I got it working! Thanks again