|
Pro Android with Kotlin@de android telegram Pro Android with Kotlin Developing Modern Mobile20
CHAPTER 3: Activities
When an intent is used on the invoker side, you can add categories by writing the following,
for example:
val intent:Intent = Intent(...)
intent.addCategory("android.intent.category.ALTERNATIVE")
Standard categories correspond to constants with names like
CATEGORY_*
inside the
android.content.Intent
class. You can find them listed in the section “Intent Constituent
Parts” in the online text companion.
Caution
For implicit intents, you
must
use the
DEFAULT
category inside the filter. This is
because the methods
startActivity()
and
startActivityForResult()
use this category
by default.
Intent Data
The
child of the filter is a data type specification for the filter. The syntax is as follows:
android:host="string"
android:port="string"
android:path="string"
android:pathPattern="string"
android:pathPrefix="string"
android:mimeType="string" />
You can specify either of the following or both of the following:
A data type specified by only the
mimeType
element, for example,
text/
plain
or
text/html
. So, you can write the following:
A data type specified by scheme, host, port, and some path
specification:
://:
[
|
|
Pattern>]
. Here
means the full path,
is the start
of a path, and
is like a path but with wildcards:
X*
is
zero or more occurrences of the character
X
, and
.*
is zero or more
occurrences of any character. Because of escaping rules, write \\* for an
asterisk and \\\\ for a backslash.
On the caller side, you can use
setType()
,
setData()
, and
setDataAndType()
to set any data
type combination.
|
|
|