global_jvm = vm;
// Invoke Nit system and main
+ int main(int argc, char ** argv);
main(0, NULL);
return JNI_VERSION_1_2;
Activity_on_restore_instance_state((Activity)nit_activity, saved_state);
}
+ JNIEXPORT jboolean JNICALL Java_nit_app_NitActivity_nitOnBackPressed
+ (JNIEnv *env, jobject java_activity, jint nit_activity)
+ {
+ return (jboolean)Activity_on_back_pressed((Activity)nit_activity);
+ }
+
JNIEXPORT jboolean JNICALL Java_nit_app_NitActivity_nitOnKeyDown
(JNIEnv *env, jobject java_activity, jint nit_activity, jint keyCode, jobject event)
{
Activity.on_start, Activity.on_restart, Activity.on_stop,
Activity.on_pause, Activity.on_resume,
Activity.on_save_instance_state, Activity.on_restore_instance_state,
+ Activity.on_back_pressed,
Activity.on_key_down, Activity.on_key_long_press,
Activity.on_key_multiple, Activity.on_key_up `{
App_incr_ref(self);
end
end
+redef class AppComponent
+ # The application is starting or restarting, it is visible to the user
+ fun on_start do end
+
+ # The application is being destroyed
+ fun on_destroy do end
+end
+
# An Android activity
#
# You must implement the callbacks (prefixed with `on_`) to follow the
# Notification from Android, the activity has been restarted
#
# Followed by `on_start`.
- fun on_restart do end
+ fun on_restart do app.on_restart
# Notification from Android, the activity has been started
#
# Notification from Android, the system is running low on memory
#
# Try to reduce your memory use.
- fun on_low_memory do end
+ fun on_low_memory do force_garbage_collection
# Notification from Android, the current window of the activity has lost or gained focus
fun on_window_focus_changed(has_focus: Bool) do end
# Notification from Android, the current device configuration has changed
fun on_configuration_changed do end
+ # The back key has been pressed
+ #
+ # Return `true` if the event has been handled.
+ fun on_back_pressed: Bool do return false
+
# A key has been pressed
#
# Return `true` if the event has been handled.