import simple
import mnit_android
-super
+in "Java" `{
+ import android.content.Context;
+ import android.widget.Toast;
+`}
+
+redef class MyApp
+ redef fun input( ie )
+ do
+ if ie isa PointerEvent and ie.depressed then do_java_stuff
+
+ return super
+ end
+
+ fun do_java_stuff import native_activity in "Java" `{
+ // + Log (no context needed)
+ android.util.Log.d("mnit_simple", "Java within NIT!!!");
+
+ // - Context needed from now on
+ // NativeActivity is a Java sub-class of Context
+ final android.app.NativeActivity context = MyApp_native_activity(recv);
+
+ // - UI thread needed from now on
+ context.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ // + Toast
+ CharSequence text = "Java within Nit!";
+ int duration = Toast.LENGTH_SHORT;
+ Toast toast = Toast.makeText(context, text, duration);
+ toast.show();
+ }
+ });
+ `}
+end