examples: update mnit_simple to android.nit
[nit.git] / examples / mnit_simple / src / simple_android.nit
index 8d05277..157bc7e 100644 (file)
@@ -16,6 +16,7 @@
 
 module simple_android is
        java_package("org.nitlanguage.simple")
+       android_manifest("""<uses-permission android:name="android.permission.VIBRATE" />""")
 end
 
 import simple
@@ -26,7 +27,7 @@ in "Java" `{
        import android.widget.Toast;
 `}
 
-redef class MyApp
+redef class App
        redef fun input( ie )
        do
                if ie isa PointerEvent and ie.depressed then do_java_stuff
@@ -40,7 +41,12 @@ redef class MyApp
 
                // - Context needed from now on
                // NativeActivity is a Java sub-class of Context
-               final android.app.NativeActivity context = MyApp_native_activity(recv);
+               final android.app.NativeActivity context = App_native_activity(recv);
+
+               // Vibration
+               android.os.Vibrator v = (android.os.Vibrator)
+                       context.getSystemService(android.content.Context.VIBRATOR_SERVICE);
+               v.vibrate(500);
 
                // - UI thread needed from now on
                context.runOnUiThread(new Runnable() {