Property definitions

android $ Intent :: defaultinit
# Services allowing to launch an activity and start/stop services
class Intent
	protected var intent: NativeIntent = (new NativeIntent).new_global_ref is lazy

	# The general action to be performed
	#
	# ~~~nitish
	# # TODO better example
	# intent.action = intent_action.view.to_s
	# ~~~
	fun action=(action: String)
	do
		sys.jni_env.push_local_frame(1)
		intent.action = action.to_java_string
		sys.jni_env.pop_local_frame
	end

	# Returns the action to be performed or `null` if none
	fun action: nullable String do
		var result = intent.action.to_s
		if result == "" then return null
		return result
	end

	# Add category to the intent
	# Only activities providing all of the requested categories will be used
	#
	# ~~~nitish
	# # TODO better example
	# intent.add_category(intent_category.home.to_s)
	# ~~~
	# Returns `self` allowing fluent programming
	fun add_category(category: String): Intent
	do
		sys.jni_env.push_local_frame(1)
		intent.add_category(category.to_java_string)
		sys.jni_env.pop_local_frame
		return self
	end

	# Returns all the intent categories or `null` if none
	fun categories: nullable HashSet[String]
	do
		var string_set = intent.categories
		if string_set.is_empty then return null

		return string_set
	end

	# Sets the data uri the intent is working on
	# Automatically clears the type field set using `mime_type=` method as it
	# uses the data uri to determine the MIME type
	# Note: The Uri string has to comply with RFC 2396
	fun data=(data_uri: String)
	do
		sys.jni_env.push_local_frame(1)
		intent.data = data_uri.to_java_string
		sys.jni_env.pop_local_frame
	end

	# Returns the data Uri the data is operating on or `null` if none
	fun data: nullable String
	do
		var result = intent.data.to_s
		if result == "" then return null
		return result
	end

	# Sets an explicit MIME data type to be handled by the intent, for example
	# the return data type
	# Automatically clears the data type field set using `data=` method
	fun mime_type=(mime_type: String)
	do
		sys.jni_env.push_local_frame(1)
		intent.mime_type = mime_type.to_java_string
		sys.jni_env.pop_local_frame
	end

	# Add a flag to be used by the intent
	#
	# ~~~nitish
	# # TODO better example
	# intent.add_flags(intent_flag.activity_new_task)
	# ~~~
	# Returns `self` allowing fluent programming
	fun add_flags(flags: Int): Intent
	do
		intent.add_flags(flags)
		return self
	end

	# Returns an `Int` representing all the intent flags
	fun flags: Int do return intent.flags

	# Returns the package name the intent resolution is limited to
	# Returns `null` if not defined
	fun package_name: nullable String do
		var result = intent.get_package.to_s
		if result == "" then return null
		return result
	end

	# Returns the set MIME and `null` if none
	fun type_name: nullable String do
		var result = intent.get_type.to_s
		if result == "" then return null
		return result
	end

	# Returns `true` if the intent contains the given category
	fun has_category(category: String): Bool
	do
		sys.jni_env.push_local_frame(1)
		var return_value = intent.has_category(category.to_java_string)
		sys.jni_env.pop_local_frame
		return return_value
	end

	# Returns `true` if the intent contains the given extra
	fun has_extra(extra: String): Bool
	do
		sys.jni_env.push_local_frame(1)
		var return_value = intent.has_extra(extra.to_java_string)
		sys.jni_env.pop_local_frame
		return return_value
	end

	# Removes the given category
	# Returns `self` allowing fluent programming
	fun remove_category(category: String): Intent
	do
		sys.jni_env.push_local_frame(1)
		intent.remove_category(category.to_java_string)
		sys.jni_env.pop_local_frame
		return self
	end

	# Removes the given extra
	# Returns `self` allowing fluent programming
	fun remove_extra(name: String): Intent
	do
		sys.jni_env.push_local_frame(1)
		intent.remove_extra(name.to_java_string)
		sys.jni_env.pop_local_frame
		return self
	end

	# Retrieves the `Array[Bool]` extra stored as Java `boolean[]` with the
	# corresponding name
	fun extra_bool_array(name: String): Array[Bool]
	do
		sys.jni_env.push_local_frame(1)
		var nit_array = intent.boolean_array_extra(name.to_java_string)
		sys.jni_env.pop_local_frame
		return nit_array
	end

	# Retrieves the `Bool` extra stored with the corresponding name
	fun extra_bool(name: String, def_value: Bool): Bool
	do
		sys.jni_env.push_local_frame(1)
		var nit_bool = intent.boolean_extra(name.to_java_string, def_value)
		sys.jni_env.pop_local_frame
		return nit_bool
	end

	# Retrieves the `Array[Int]` extra stored as Java `byte[]` with the
	# corresponding name
	fun extra_byte_array(name: String): Array[Int]
	do
		sys.jni_env.push_local_frame(1)
		var nit_array = intent.byte_array_extra(name.to_java_string)
		sys.jni_env.pop_local_frame
		return nit_array
	end

	# Retrieves the `Int` extra stored as Java `byte` with the corresponding name
	fun extra_byte(name: String, def_value: Int): Int
	do
		sys.jni_env.push_local_frame(1)
		var nit_int = intent.byte_extra(name.to_java_string, def_value)
		sys.jni_env.pop_local_frame
		return nit_int
	end

	# Retrieves the `Array[Char]` extra stored as Java `char[]` with the
	# corresponding name
	# FIXME: Java's `char` are encoded on 16-bits whereas Nit's are on 8-bits.
	fun extra_char_array(name: String): Array[Char]
	do
		sys.jni_env.push_local_frame(1)
		var nit_array = intent.char_array_extra(name.to_java_string)
		sys.jni_env.pop_local_frame
		return nit_array
	end

	# Retrieves the `Char` extra stored as Java `char` with the
	# corresponding name
	# FIXME: Java's `char` are encoded on 16-bits whereas Nit's are on 8-bits.
	fun extra_char(name: String, def_value: Char): Char
	do
		sys.jni_env.push_local_frame(1)
		var nit_char = intent.char_extra(name.to_java_string, def_value)
		sys.jni_env.pop_local_frame
		return nit_char
	end

	# Retrieves the `String` extra stored as Java `CharSequence` with the
	# corresponding name
	fun extra_char_sequence(name: String, def_value: String ): String
	do
		sys.jni_env.push_local_frame(1)
		var nit_charseq =
			intent.char_sequence_extra(name.to_java_string).to_s
		sys.jni_env.pop_local_frame
		return nit_charseq
	end

	# Retrieves the `Array[String]` extra stored as Java `ArrayList<CharSequence>`
	# with the corresponding name
	fun extra_char_sequence_array_list_extra(name: String): Array[String]
	do
		sys.jni_env.push_local_frame(1)
		var string_array = intent.char_sequence_array_list_extra(name.to_java_string)
		sys.jni_env.pop_local_frame
		return string_array
	end

	# Retrieves the `Array[String]` extra stored as Java `CharSequence[]`
	# with the corresponding name
	fun extra_char_sequence_array(name: String): Array[String]
	do
		sys.jni_env.push_local_frame(1)
		var string_array = intent.char_sequence_array_list_extra(name.to_java_string)
		sys.jni_env.pop_local_frame
		return string_array
	end

	# Retrieves the `Array[Float]` extra stored as Java `double[]` with the
	# corresponding name
	fun extra_double_array(name: String): Array[Float]
	do
		sys.jni_env.push_local_frame(1)
		var nit_array = intent.double_array_extra(name.to_java_string)
		sys.jni_env.pop_local_frame
		return nit_array
	end

	# Retrieves the `Float` extra stored as Java `double` with the corresponding
	# name
	fun extra_double(name: String, def_value: Float): Float
	do
		sys.jni_env.push_local_frame(1)
		var nit_float = intent.double_extra(name.to_java_string, def_value)
		sys.jni_env.pop_local_frame
		return nit_float
	end

	# Retrieves the `Array[Float]` extra stored as Java `float[]` with the
	# corresponding name
	fun extra_float_array(name: String): Array[Float]
	do
		sys.jni_env.push_local_frame(1)
		var nit_array = intent.float_array_extra(name.to_java_string)
		sys.jni_env.pop_local_frame
		return nit_array
	end

	# Retrieves the `Float` extra stored as Java `float` with the corresponding
	# name
	fun extra_float(name: String, def_value: Float): Float
	do
		sys.jni_env.push_local_frame(1)
		var nit_float = intent.float_extra(name.to_java_string, def_value)
		sys.jni_env.pop_local_frame
		return nit_float
	end

	# Retrieves the `Array[Int]` extra stored as Java `int[]` with the
	# corresponding name
	fun extra_int_array(name: String): Array[Int]
	do
		sys.jni_env.push_local_frame(1)
		var nit_array = intent.int_array_extra(name.to_java_string)
		sys.jni_env.pop_local_frame
		return nit_array
	end

	# Retrieves the `Int` extra stored as Java `int` with the corresponding
	# name
	fun extra_int(name: String, def_value: Int): Int
	do
		sys.jni_env.push_local_frame(1)
		var nit_int = intent.int_extra(name.to_java_string, def_value)
		sys.jni_env.pop_local_frame
		return nit_int
	end

	# Retrieves the `Array[Int]` extra stored as Java `long[]` with the
	# corresponding name
	fun extra_long_array(name: String): Array[Int]
	do
		sys.jni_env.push_local_frame(1)
		var nit_array = intent.long_array_extra(name.to_java_string)
		sys.jni_env.pop_local_frame
		return nit_array
	end

	# Retrieves the `Int` extra stored as Java `long` with the corresponding
	# name
	fun extra_long(name: String, def_value: Int): Int
	do
		sys.jni_env.push_local_frame(1)
		var nit_int = intent.long_extra(name.to_java_string, def_value)
		sys.jni_env.pop_local_frame
		return nit_int
	end

	# Retrieves the `Array[Int]` extra stored as Java `short[]` with the
	# corresponding name
	fun extra_short_array(name: String): Array[Int]
	do
		sys.jni_env.push_local_frame(1)
		var nit_array = intent.short_array_extra(name.to_java_string)
		sys.jni_env.pop_local_frame
		return nit_array
	end

	# Retrieves the `Int` extra stored as Java `short` with the corresponding
	# name
	fun extra_short(name: String, def_value: Int): Int
	do
		sys.jni_env.push_local_frame(1)
		var nit_int = intent.short_extra(name.to_java_string, def_value)
		sys.jni_env.pop_local_frame
		return nit_int
	end

	# Retrieves the `Array[String]` extra stored as Java `String[]` with the
	# corresponding name
	fun extra_string_array(name: String): Array[String]
	do
		sys.jni_env.push_local_frame(1)
		var string_array = intent.string_array_extra(name.to_java_string)
		sys.jni_env.pop_local_frame
		return string_array
	end

	# Retrieves the `Array[String]` extra stored as Java `ArrayList<String>`
	# with the corresponding name
	fun extra_string_array_list(name: String): Array[String]
	do
		sys.jni_env.push_local_frame(1)
		var string_array = intent.string_array_list_extra(name.to_java_string)
		sys.jni_env.pop_local_frame
		return string_array
	end

	# Retrieves the `String` extra stored as Java `String` with the corresponding
	# name
	fun extra_string(name: String): String
	do
		sys.jni_env.push_local_frame(1)
		var nit_java_string = intent.string_extra(name.to_java_string).to_s
		sys.jni_env.pop_local_frame
		return nit_java_string
	end

	# Adds extra data corresponding to `double` java type
	# Returns `self` allowing fluent programming
	fun add_extra_double(name: String, value: Float): Intent
	do
		sys.jni_env.push_local_frame(1)
		intent.add_extra_double(name.to_java_string, value)
		sys.jni_env.pop_local_frame
		return self
	end

	# Adds extra data corresponding to `double[]` java type
	# Returns `self` allowing fluent programming
	fun add_extra_array_of_double(name: String, value: Array[Float]): Intent
	do
		sys.jni_env.push_local_frame(1)
		intent.add_extra_array_of_double(name.to_java_string, value)
		sys.jni_env.pop_local_frame
		return self
	end

	# Adds extra data corresponding to `char` java type
	# Returns `self` allowing fluent programming
	# FIXME: Java's `char` are encoded on 16-bits whereas Nit's are on 8-bits.
	fun add_extra_char(name: String, value: Char): Intent
	do
		sys.jni_env.push_local_frame(1)
		intent.add_extra_char(name.to_java_string, value)
		sys.jni_env.pop_local_frame
		return self
	end

	# Adds extra data corresponding to `char[]` java type
	# Returns `self` allowing fluent programming
	# FIXME: Java's `char` are encoded on 16-bits whereas Nit's are on 8-bits.
	fun add_extra_array_of_char(name: String, value: Array[Char]): Intent
	do
		sys.jni_env.push_local_frame(1)
		intent.add_extra_array_of_char(name.to_java_string, value)
		sys.jni_env.pop_local_frame
		return self
	end

	# Adds extra data corresponding to `CharSequence` java type
	# Returns `self` allowing fluent programming
	fun add_extra_char_sequence(name: String, value: String): Intent
	do
		sys.jni_env.push_local_frame(2)
		intent.add_extra_char_sequence(name.to_java_string, value.to_java_string)
		sys.jni_env.pop_local_frame
		return self
	end

	# Adds extra data corresponding to `CharSequence[]` java type
	# Returns `self` allowing fluent programming
	fun add_extra_array_of_char_sequence(name: String, value: Array[String]): Intent
	do
		sys.jni_env.push_local_frame(value.length + 1)
		var java_string_array = new Array[JavaString]
		for element in value do
			java_string_array.push(element.to_java_string)
		end
		intent.add_extra_array_of_char_sequence(name.to_java_string, java_string_array)
		sys.jni_env.pop_local_frame
		return self
	end

	# Adds extra data corresponding to `bundle` java type
	# Returns `self` allowing fluent programming
	fun add_extra_bundle(name: String, value: NativeBundle): Intent
	do
		sys.jni_env.push_local_frame(1)
		intent.add_extra_bundle(name.to_java_string, value)
		sys.jni_env.pop_local_frame
		return self
	end

	# Adds extra data corresponding to `int` java type
	# Returns `self` allowing fluent programming
	# *Be aware of possible integer overflow as Nit `Int` corresponds to*
	# *java `long` and the expected value is a java `int`*
	# Consider using add_extra_long instead
	fun add_extra_int(name: String, value: Int): Intent
	do
		sys.jni_env.push_local_frame(1)
		intent.add_extra_int(name.to_java_string, value)
		sys.jni_env.pop_local_frame
		return self
	end

	# Adds extra data corresponding to `int[]` java type
	# Returns `self` allowing fluent programming
	# *Be aware of possible integer overflow as Nit `Int` corresponds to*
	# *java `long` and the expected value is a java `int[]`*
	# Consider using add_extra_array_of_long instead
	fun add_extra_array_of_int(name: String, value: Array[Int]): Intent
	do
		sys.jni_env.push_local_frame(1)
		intent.add_extra_array_of_int(name.to_java_string, value)
		sys.jni_env.pop_local_frame
		return self
	end

	# Adds extra data corresponding to `ArrayList<Integer>` java type
	# Returns `self` allowing fluent programming
	# *Be aware of possible integer overflow as Nit `Int` corresponds to*
	# *java `long` and the expected value is a java `ArrayList<Integer>`*
	# Consider using add_extra_array_of_long instead
	fun add_extra_array_list_of_int(name: String, value: Array[Int]): Intent
	do
		sys.jni_env.push_local_frame(1)
		intent.add_extra_array_list_of_int(name.to_java_string, value)
		sys.jni_env.pop_local_frame
		return self
	end

	# Adds extra data corresponding to `byte` java type
	# Returns `self` allowing fluent programming
	# *Be aware of possible integer overflow as Nit `Int` corresponds to*
	# *java `long` and the expected value is a java `byte`*
	# Consider using add_extra_array_of_long instead
	fun add_extra_byte(name: String, value: Int): Intent
	do
		sys.jni_env.push_local_frame(1)
		intent.add_extra_byte(name.to_java_string, value)
		sys.jni_env.pop_local_frame
		return self
	end

	# Adds extra data corresponding to `byte[]` java type
	# Returns `self` allowing fluent programming
	# *Be aware of possible integer overflow as Nit `Int` corresponds to*
	# *java `long` and the expected value is a java `byte[]`*
	# Consider using add_extra_array_of_long instead
	fun add_extra_array_of_byte(name: String, value: Int): Intent
	do
		sys.jni_env.push_local_frame(1)
		intent.add_extra_array_of_byte(name.to_java_string, value)
		sys.jni_env.pop_local_frame
		return self
	end

	# Adds extra data corresponding to `long` java type
	# Returns `self` allowing fluent programming
	fun add_extra_long(name: String, value: Int): Intent
	do
		sys.jni_env.push_local_frame(1)
		intent.add_extra_long(name.to_java_string, value)
		sys.jni_env.pop_local_frame
		return self
	end

	# Adds extra data corresponding to `long[]` java type
	# Returns `self` allowing fluent programming
	fun add_extra_array_of_long(name: String, value: Array[Int]): Intent
	do
		sys.jni_env.push_local_frame(1)
		intent.add_extra_array_of_long(name.to_java_string, value)
		sys.jni_env.pop_local_frame
		return self
	end

	# Adds extra data corresponding to `float` java type
	# Returns `self` allowing fluent programming
	# *Be aware of possible loss of precision as Nit `Float` corresponds to*
	# *java `double` and the expected value is a java `float`*
	# Consider using add_extra_double
	fun add_extra_float(name: String, value: Float): Intent
	do
		sys.jni_env.push_local_frame(1)
		intent.add_extra_float(name.to_java_string, value)
		sys.jni_env.pop_local_frame
		return self
	end

	# Adds extra data corresponding to `float[]` java type
	# Returns `self` allowing fluent programming
	# *Be aware of possible loss of precision as Nit `Float` corresponds to*
	# *java `double` and the expected value is a java `float[]`*
	# Consider using add_extra_array_of_double
	fun add_extra_array_of_float(name: String, value: Array[Float]): Intent
	do
		sys.jni_env.push_local_frame(1)
		intent.add_extra_array_of_float(name.to_java_string, value)
		sys.jni_env.pop_local_frame
		return self
	end

	# Adds extra data corresponding to `String` java type
	# Returns `self` allowing fluent programming
	fun add_extra_string(name: String, value: String): Intent
	do
		sys.jni_env.push_local_frame(2)
		intent.add_extra_string(name.to_java_string, value.to_java_string)
		sys.jni_env.pop_local_frame
		return self
	end

	# Adds extra data corresponding to `String[]` java type
	# Returns `self` allowing fluent programming
	fun add_extra_array_of_string(name: String, value: Array[String]): Intent
	do
		sys.jni_env.push_local_frame(value.length + 1)
		var java_string_array = new Array[JavaString]
		for element in value do
			java_string_array.push(element.to_java_string)
		end
		intent.add_extra_array_of_string(name.to_java_string, java_string_array)
		sys.jni_env.pop_local_frame
		return self
	end

	# Adds extra data corresponding to `ArrayList<String>` java type
	# Returns `self` allowing fluent programming
	fun add_extra_array_list_of_string(name: String, value: Array[String]): Intent
	do
		sys.jni_env.push_local_frame(value.length + 1)
		var java_string_array = new Array[JavaString]
		for element in value do
			java_string_array.push(element.to_java_string)
		end

		intent.add_extra_array_list_of_string(name.to_java_string, java_string_array)
		sys.jni_env.pop_local_frame
		return self
	end

	# Adds extra data corresponding to `boolean` java type
	# Returns `self` allowing fluent programming
	fun add_extra_bool(name: String, value: Bool): Intent
	do
		sys.jni_env.push_local_frame(1)
		intent.add_extra_bool(name.to_java_string, value)
		sys.jni_env.pop_local_frame
		return self
	end

	# Adds extra data corresponding to `boolean[]` java type
	# Returns `self` allowing fluent programming
	fun add_extra_array_of_bool(name: String, value: Array[Bool]): Intent
	do
		sys.jni_env.push_local_frame(1)
		intent.add_extra_array_of_bool(name.to_java_string, value)
		sys.jni_env.pop_local_frame
		return self
	end

	# Adds extra data corresponding to `short` java type
	# Returns `self` allowing fluent programming
	# *Be aware of possible integer overflow as Nit `Int` corresponds to*
	# *java `long` and the expected value is a java `short`*
	# Consider using add_extra_long instead
	fun add_extra_short(name: String, value: Int): Intent
	do
		sys.jni_env.push_local_frame(1)
		intent.add_extra_short(name.to_java_string, value)
		sys.jni_env.pop_local_frame
		return self
	end

	# Adds extra data corresponding to `short[]` java type
	# Returns `self` allowing fluent programming
	# *Be aware of possible integer overflow as Nit `Int` corresponds to*
	# *java `long` and the expected value is a java `short[]`*
	# Consider using add_extra_array_of_long instead
	fun add_extra_array_of_short(name: String, value: Array[Int]): Intent
	do
		sys.jni_env.push_local_frame(1)
		intent.add_extra_array_of_short(name.to_java_string, value)
		sys.jni_env.pop_local_frame
		return self
	end

	# Store `value` as a serialized Json string
	# java method according to value type
	# Returns `self` allowing fluent programming
	fun []=(name: String, value: nullable Serializable): Intent
	do
		var serialized_string = new StringWriter
		var serializer = new JsonSerializer(serialized_string)
		serializer.serialize(value)

		add_extra_string(name, serialized_string.to_s)
		return self
	end

	# Retrieve an `Object` stored via `[]=` function
	fun [](name: String): nullable Object
	do
		var serialized_string = self.extra_string(name)
		if serialized_string == "" then return null

		var deserializer = new JsonDeserializer(serialized_string)
		return deserializer.deserialize
	end

	# Specify the class to be launched by the intent
	fun set_class_name(package_name: String, class_name: String): Intent
	do
		sys.jni_env.push_local_frame(2)
		intent.set_class_name(package_name.to_java_string, class_name.to_java_string)
		sys.jni_env.pop_local_frame
		return self
	end

	# Deletes intent global reference
	fun destroy do self.intent.delete_global_ref

	# Returns a human readable representation of the intent
	redef fun to_s do return intent.to_native_s.to_s
end
lib/android/intent/intent_api10.nit:630,1--1307,3