An Android activity

You must implement the callbacks (prefixed with on_) to follow the standard Android life-cycle.

Introduced properties

fun native: NativeActivity

android :: Activity :: native

Native Java activity
protected fun native=(native: NativeActivity)

android :: Activity :: native=

Native Java activity
fun on_back_pressed: Bool

android :: Activity :: on_back_pressed

The back key has been pressed
fun on_configuration_changed

android :: Activity :: on_configuration_changed

Notification from Android, the current device configuration has changed
fun on_create(save_state: NativeBundle)

android :: Activity :: on_create

Notification from Android, the activity is created
fun on_destroy

android :: Activity :: on_destroy

Notification from Android, the activity is being destroyed
fun on_key_down(key_code: Int, event: NativeKeyEvent): Bool

android :: Activity :: on_key_down

A key has been pressed
fun on_key_long_press(key_code: Int, event: NativeKeyEvent): Bool

android :: Activity :: on_key_long_press

A key has been long pressed
fun on_key_multiple(key_code: Int, count: Int, event: NativeKeyEvent): Bool

android :: Activity :: on_key_multiple

Multiple down/up pairs of the same key have occurred in a row
fun on_key_up(key_code: Int, event: NativeKeyEvent): Bool

android :: Activity :: on_key_up

A key has been released
fun on_low_memory

android :: Activity :: on_low_memory

Notification from Android, the system is running low on memory
fun on_pause

android :: Activity :: on_pause

Notification from Android, the activity has been paused
fun on_restart

android :: Activity :: on_restart

Notification from Android, the activity has been restarted
fun on_restore_instance_state(save_state: NativeBundle)

android :: Activity :: on_restore_instance_state

Notification from Android, the activity is being re-initialized from a save_state
fun on_resume

android :: Activity :: on_resume

Notification from Android, the activity has been resumed
fun on_save_instance_state(save_state: NativeBundle)

android :: Activity :: on_save_instance_state

Notification from Android, the activity may be stopped, save state
fun on_start

android :: Activity :: on_start

Notification from Android, the activity has been started
fun on_stop

android :: Activity :: on_stop

Notification from Android, the activity has been stopped
fun on_window_focus_changed(has_focus: Bool)

android :: Activity :: on_window_focus_changed

Notification from Android, the current window of the activity has lost or gained focus

Redefined properties

redef type SELF: Activity

android $ Activity :: SELF

Type of this instance, automatically specialized in every class
redef fun on_back_pressed: Bool

android :: ui $ Activity :: on_back_pressed

The back key has been pressed

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
fun native: NativeActivity

android :: Activity :: native

Native Java activity
protected fun native=(native: NativeActivity)

android :: Activity :: native=

Native Java activity
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun on_back_pressed: Bool

android :: Activity :: on_back_pressed

The back key has been pressed
fun on_configuration_changed

android :: Activity :: on_configuration_changed

Notification from Android, the current device configuration has changed
fun on_create(save_state: NativeBundle)

android :: Activity :: on_create

Notification from Android, the activity is created
fun on_destroy

android :: Activity :: on_destroy

Notification from Android, the activity is being destroyed
fun on_key_down(key_code: Int, event: NativeKeyEvent): Bool

android :: Activity :: on_key_down

A key has been pressed
fun on_key_long_press(key_code: Int, event: NativeKeyEvent): Bool

android :: Activity :: on_key_long_press

A key has been long pressed
fun on_key_multiple(key_code: Int, count: Int, event: NativeKeyEvent): Bool

android :: Activity :: on_key_multiple

Multiple down/up pairs of the same key have occurred in a row
fun on_key_up(key_code: Int, event: NativeKeyEvent): Bool

android :: Activity :: on_key_up

A key has been released
fun on_low_memory

android :: Activity :: on_low_memory

Notification from Android, the system is running low on memory
fun on_pause

android :: Activity :: on_pause

Notification from Android, the activity has been paused
fun on_restart

android :: Activity :: on_restart

Notification from Android, the activity has been restarted
fun on_restore_instance_state(save_state: NativeBundle)

android :: Activity :: on_restore_instance_state

Notification from Android, the activity is being re-initialized from a save_state
fun on_resume

android :: Activity :: on_resume

Notification from Android, the activity has been resumed
fun on_save_instance_state(save_state: NativeBundle)

android :: Activity :: on_save_instance_state

Notification from Android, the activity may be stopped, save state
fun on_start

android :: Activity :: on_start

Notification from Android, the activity has been started
fun on_stop

android :: Activity :: on_stop

Notification from Android, the activity has been stopped
fun on_window_focus_changed(has_focus: Bool)

android :: Activity :: on_window_focus_changed

Notification from Android, the current window of the activity has lost or gained focus
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
package_diagram android::Activity Activity core::Object Object android::Activity->core::Object

Parents

interface Object

core :: Object

The root of the class hierarchy.

Class definitions

android $ Activity
# 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

android :: ui $ Activity
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