An Android notification, shown at the top of the screen

Introduced properties

private var _id: nullable Int

android :: Notification :: _id

private var _number: nullable Int

android :: Notification :: _number

Number to display on the bottom right part of the notification
private var _ongoing: Bool

android :: Notification :: _ongoing

Is this notification ongoing? Not user dismissable.
private var _small_icon: nullable Text

android :: Notification :: _small_icon

Name of a resource found in the res/drawable-* folders to use for the small icon
private var _tag: String

android :: Notification :: _tag

private var _text: nullable Text

android :: Notification :: _text

Text content of this notification
private var _ticker: nullable Text

android :: Notification :: _ticker

Text to show in the bar as the notification appears
private var _title: nullable Text

android :: Notification :: _title

Title of this notification
fun cancel

android :: Notification :: cancel

Cancel this notification and hide it if it is currently displayed
init defaultinit(title: nullable Text, text: nullable Text)

android :: Notification :: defaultinit

private fun id: nullable Int

android :: Notification :: id

private fun id=(id: nullable Int)

android :: Notification :: id=

fun number: nullable Int

android :: Notification :: number

Number to display on the bottom right part of the notification
fun number=(number: nullable Int)

android :: Notification :: number=

Number to display on the bottom right part of the notification
fun ongoing: Bool

android :: Notification :: ongoing

Is this notification ongoing? Not user dismissable.
fun ongoing=(ongoing: Bool)

android :: Notification :: ongoing=

Is this notification ongoing? Not user dismissable.
fun show

android :: Notification :: show

Show the notification
fun small_icon: nullable Text

android :: Notification :: small_icon

Name of a resource found in the res/drawable-* folders to use for the small icon
fun small_icon=(small_icon: nullable Text)

android :: Notification :: small_icon=

Name of a resource found in the res/drawable-* folders to use for the small icon
private fun tag: String

android :: Notification :: tag

private fun tag=(tag: String)

android :: Notification :: tag=

fun text: nullable Text

android :: Notification :: text

Text content of this notification
fun text=(text: nullable Text)

android :: Notification :: text=

Text content of this notification
fun ticker: nullable Text

android :: Notification :: ticker

Text to show in the bar as the notification appears
fun ticker=(ticker: nullable Text)

android :: Notification :: ticker=

Text to show in the bar as the notification appears
fun title: nullable Text

android :: Notification :: title

Title of this notification
fun title=(title: nullable Text)

android :: Notification :: title=

Title of this notification
private fun was_shown: Bool

android :: Notification :: was_shown

Was this notification shown with show?

Redefined properties

redef type SELF: Notification

android $ Notification :: SELF

Type of this instance, automatically specialized in every class

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
private var _id: nullable Int

android :: Notification :: _id

private var _number: nullable Int

android :: Notification :: _number

Number to display on the bottom right part of the notification
private var _ongoing: Bool

android :: Notification :: _ongoing

Is this notification ongoing? Not user dismissable.
private var _small_icon: nullable Text

android :: Notification :: _small_icon

Name of a resource found in the res/drawable-* folders to use for the small icon
private var _tag: String

android :: Notification :: _tag

private var _text: nullable Text

android :: Notification :: _text

Text content of this notification
private var _ticker: nullable Text

android :: Notification :: _ticker

Text to show in the bar as the notification appears
private var _title: nullable Text

android :: Notification :: _title

Title of this notification
fun cancel

android :: Notification :: cancel

Cancel this notification and hide it if it is currently displayed
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.
init defaultinit(title: nullable Text, text: nullable Text)

android :: Notification :: defaultinit

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.
private fun id: nullable Int

android :: Notification :: id

private fun id=(id: nullable Int)

android :: Notification :: id=

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.
private intern fun native_class_name: CString

core :: Object :: native_class_name

The class name of the object in CString format.
fun number: nullable Int

android :: Notification :: number

Number to display on the bottom right part of the notification
fun number=(number: nullable Int)

android :: Notification :: number=

Number to display on the bottom right part of the notification
intern fun object_id: Int

core :: Object :: object_id

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

android :: Notification :: ongoing

Is this notification ongoing? Not user dismissable.
fun ongoing=(ongoing: Bool)

android :: Notification :: ongoing=

Is this notification ongoing? Not user dismissable.
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
fun show

android :: Notification :: show

Show the notification
fun small_icon: nullable Text

android :: Notification :: small_icon

Name of a resource found in the res/drawable-* folders to use for the small icon
fun small_icon=(small_icon: nullable Text)

android :: Notification :: small_icon=

Name of a resource found in the res/drawable-* folders to use for the small icon
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
private fun tag: String

android :: Notification :: tag

private fun tag=(tag: String)

android :: Notification :: tag=

fun text: nullable Text

android :: Notification :: text

Text content of this notification
fun text=(text: nullable Text)

android :: Notification :: text=

Text content of this notification
fun ticker: nullable Text

android :: Notification :: ticker

Text to show in the bar as the notification appears
fun ticker=(ticker: nullable Text)

android :: Notification :: ticker=

Text to show in the bar as the notification appears
fun title: nullable Text

android :: Notification :: title

Title of this notification
fun title=(title: nullable Text)

android :: Notification :: title=

Title of this notification
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
private fun was_shown: Bool

android :: Notification :: was_shown

Was this notification shown with show?
package_diagram android::Notification Notification core::Object Object android::Notification->core::Object

Parents

interface Object

core :: Object

The root of the class hierarchy.

Class definitions

android $ Notification
# An Android notification, shown at the top of the screen
class Notification
	# Title of this notification
	var title: nullable Text is writable

	# Text content of this notification
	var text: nullable Text is writable

	# Text to show in the bar as the notification appears
	var ticker: nullable Text = null is writable

	# Name of a resource found in the `res/drawable-*` folders to use for the small icon
	#
	# By default, we use the app's icon, named "icon". A valid icon must be used
	# to display notifications.
	var small_icon: nullable Text = null is writable

	# Number to display on the bottom right part of the notification
	var number: nullable Int = null is writable

	# Is this notification ongoing? Not user dismissable.
	var ongoing: Bool = false is writable

	private var id: nullable Int = null
	private var tag = "app.nit notification"

	# Show the notification
	fun show
	do
		sys.jni_env.push_local_frame(8)

		var context = app.native_activity
		var builder = new NativeNotificationBuilder(context)

		# If no custom icon is specified, use app's
		var small_icon = self.small_icon
		if small_icon == null then small_icon = "icon"
		var small_icon_id = app.resource_manager.other_id(small_icon.to_s, "drawable")
		builder.small_icon = small_icon_id

		# Other options
		if title != null then builder.title = title.to_java_string
		if text != null then builder.text = text.to_java_string
		if ticker != null then builder.ticker = ticker.to_java_string
		builder.ongoing = ongoing

		var notif = builder.create
		var manager = context.notification_manager

		var id = self.id
		if id == null then id = sys.next_notification_id
		manager.notify(tag.to_java_string, id, notif)

		self.id = id

		sys.jni_env.pop_local_frame
	end

	# Was this notification shown with `show`?
	#
	# This does not indicates whether is has been dismissed or not. Only that
	# it was shown at least once.
	private fun was_shown: Bool do return id != null

	# Cancel this notification and hide it if it is currently displayed
	fun cancel
	do
		var id = self.id
		if id != null then
			sys.jni_env.push_local_frame(8)

			var manager = app.native_context.notification_manager
			manager.cancel(tag.to_java_string, id)

			self.id = null

			sys.jni_env.pop_local_frame
		end
	end
end
lib/android/notification/notification.nit:41,1--120,3