You must implement the callbacks (prefixed with on_
) to follow the
standard Android life-cycle.
android :: Activity :: defaultinit
android :: Activity :: on_configuration_changed
Notification from Android, the current device configuration has changedandroid :: Activity :: on_create
Notification from Android, the activity is createdandroid :: Activity :: on_destroy
Notification from Android, the activity is being destroyedandroid :: Activity :: on_key_down
A key has been pressedandroid :: Activity :: on_key_long_press
A key has been long pressedandroid :: Activity :: on_key_multiple
Multiple down/up pairs of the same key have occurred in a rowandroid :: Activity :: on_low_memory
Notification from Android, the system is running low on memoryandroid :: Activity :: on_restart
Notification from Android, the activity has been restartedandroid :: Activity :: on_restore_instance_state
Notification from Android, the activity is being re-initialized from asave_state
android :: Activity :: on_save_instance_state
Notification from Android, the activity may be stopped, save stateandroid :: Activity :: on_window_focus_changed
Notification from Android, the current window of the activity has lost or gained focuscore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
android :: Activity :: defaultinit
core :: Object :: defaultinit
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
android :: Activity :: on_configuration_changed
Notification from Android, the current device configuration has changedandroid :: Activity :: on_create
Notification from Android, the activity is createdandroid :: Activity :: on_destroy
Notification from Android, the activity is being destroyedandroid :: Activity :: on_key_down
A key has been pressedandroid :: Activity :: on_key_long_press
A key has been long pressedandroid :: Activity :: on_key_multiple
Multiple down/up pairs of the same key have occurred in a rowandroid :: Activity :: on_low_memory
Notification from Android, the system is running low on memoryandroid :: Activity :: on_restart
Notification from Android, the activity has been restartedandroid :: Activity :: on_restore_instance_state
Notification from Android, the activity is being re-initialized from asave_state
android :: Activity :: on_save_instance_state
Notification from Android, the activity may be stopped, save stateandroid :: Activity :: on_window_focus_changed
Notification from Android, the current window of the activity has lost or gained focuscore :: Object :: output_class_name
Display class name on stdout (debug only).
# An Android activity
#
# You must implement the callbacks (prefixed with `on_`) to follow the
# standard Android life-cycle.
class Activity
# Native Java activity
var native: NativeActivity
# Notification from Android, the activity is created
#
# Do your normal static set up here.
#
# If available, `save_state` contains the activity's previous state
# as registered by `on_save_instance_state`.
#
# Followed by `on_start`.
fun on_create(save_state: NativeBundle)
do
app.on_create
app.on_restore_state
end
# Notification from Android, the activity has been restarted
#
# Followed by `on_start`.
fun on_restart do app.on_restart
# Notification from Android, the activity has been started
#
# Followed by `on_resume` or `on_stop`.
fun on_start do app.on_start
# Notification from Android, the activity has been resumed
#
# Followed by `on_pause`
fun on_resume do app.on_resume
# Notification from Android, the activity has been paused
#
# Followed by `on_resume` or `on_stop`.
fun on_pause do app.on_pause
# Notification from Android, the activity has been stopped
#
# Followed by `on_restart` or `on_destroy`.
fun on_stop do app.on_stop
# Notification from Android, the activity is being destroyed
#
# Clean up and exit.
fun on_destroy
do
app.on_destroy
native.delete_global_ref
app.activities.remove self
end
# Notification from Android, the activity is being re-initialized from a `save_state`
#
# Occurs after `on_start`.
fun on_restore_instance_state(save_state: NativeBundle) do end
# Notification from Android, the activity may be stopped, save state
#
# Occurs before `on_stop` and, without guarantee, before or after `on_pause`.
fun on_save_instance_state(save_state: NativeBundle) do app.on_save_state
# Notification from Android, the system is running low on memory
#
# Try to reduce your memory use.
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.
fun on_key_down(key_code: Int, event: NativeKeyEvent): Bool do return false
# A key has been long pressed
#
# Return `true` if the event has been handled.
fun on_key_long_press(key_code: Int, event: NativeKeyEvent): Bool do return false
# Multiple down/up pairs of the same key have occurred in a row
#
# Return `true` if the event has been handled.
fun on_key_multiple(key_code, count: Int, event: NativeKeyEvent): Bool do return false
# A key has been released
#
# Return `true` if the event has been handled.
fun on_key_up(key_code: Int, event: NativeKeyEvent): Bool do return false
end
lib/android/nit_activity.nit:219,1--322,3
redef class Activity
redef fun on_back_pressed
do
var window = app.window
if window.enable_back_button then
window.on_back_button
return true
end
return false
end
end
lib/android/ui/ui.nit:94,1--105,3