Intent

Android Intent 的包装接口。 用于封装 Intent 的创建、属性设置以及常量的访问。

Author

M8Test, [email protected], https://m8test.com

Functions

Link copied to clipboard
abstract fun addCategory(category: String): Intent

添加类别。

Link copied to clipboard
abstract fun addFlags(flags: Int): Intent

添加标志位。

Link copied to clipboard
abstract fun also(block: (Intent) -> Unit): ObjectWrapper<Intent>

对 ObjectWrapper 调用给定的 block 函数,并返回 ObjectWrapper 本身。

Link copied to clipboard
abstract fun apply(block: Intent.() -> Unit): ObjectWrapper<Intent>

对 ObjectWrapper 调用给定的 block 函数,并返回 ObjectWrapper 本身。

Link copied to clipboard
abstract fun getAction(): String?

获取当前设置的动作。

Link copied to clipboard
abstract fun getBooleanExtra(key: String, defaultValue: Boolean): Boolean

获取 Boolean 类型的额外数据。

Link copied to clipboard
abstract fun getData(): String?

获取当前设置的数据 URI 字符串。

Link copied to clipboard
abstract fun getFlags(): Int

获取当前 Intent 设置的标志位整数值。

Link copied to clipboard

获取 Intent 动作 (Actions) 的常量提供者。 包含如 ACTION_VIEW, ACTION_MAIN 等常量。

Link copied to clipboard

获取 Intent 类别 (Categories) 的常量提供者。 包含如 CATEGORY_LAUNCHER, CATEGORY_DEFAULT 等常量。

Link copied to clipboard

获取 Intent 额外数据键 (Extras Keys) 的常量提供者。 包含如 EXTRA_TEXT, EXTRA_TITLE 等常量。

Link copied to clipboard
abstract fun getIntentFlags(): IntentFlags

获取 Intent 标志位 (Flags) 的常量提供者。 包含如 FLAG_ACTIVITY_NEW_TASK 等常量。

Link copied to clipboard
abstract fun getIntExtra(key: String, defaultValue: Int): Int

获取 Int 类型的额外数据。

Link copied to clipboard
abstract fun getOrigin(): Intent

获取原始的对象.

Link copied to clipboard
abstract fun getPackage(): String?

获取当前设置的包名。

Link copied to clipboard
abstract fun getStringExtra(key: String): String?

获取 String 类型的额外数据。

Link copied to clipboard
abstract fun getType(): String?

获取当前设置的 MIME 类型。

Link copied to clipboard
abstract fun hasCategory(category: String): Boolean

判断是否包含指定类别。

Link copied to clipboard
abstract fun hasExtra(key: String): Boolean

判断是否包含指定键的额外数据。

Link copied to clipboard
abstract fun <R> let(block: (Intent) -> R): ObjectWrapper<R>?

对 ObjectWrapper 调用给定的 block 函数,并返回 block 函数的结果包装在 ObjectWrapper 中。

Link copied to clipboard
abstract fun putExtra(key: String, value: Any?): Intent

添加额外数据 (Extra)。 这是一个通用方法,会根据 value 的类型自动选择合适的 Android Intent putExtra 方法。 支持 String, Int, Boolean, Float, Double, Long 等基本类型。

Link copied to clipboard
abstract fun removeCategory(category: String)

移除类别。

Link copied to clipboard
abstract fun removeExtra(key: String)

移除指定键的额外数据。

Link copied to clipboard
abstract fun <R> run(block: Intent.() -> R): ObjectWrapper<R>?

对 ObjectWrapper 调用给定的 block 函数,并返回 block 函数的结果包装在 ObjectWrapper 中。

Link copied to clipboard
abstract fun setAction(action: String): Intent

设置 Intent 的动作 (Action)。

Link copied to clipboard
abstract fun setClassName(packageName: String, className: String): Intent

设置明确的组件名称 (ClassName)。 用于显式启动特定的 Activity 或 Service。

Link copied to clipboard
abstract fun setData(uriString: String): Intent

设置 Intent 的数据 (Data URI)。

Link copied to clipboard
abstract fun setDataAndType(uriString: String, type: String): Intent

同时设置数据和类型。 (注意:在 Android 中,单独调用 setData 会清除 Type,单独调用 setType 会清除 Data,如果需要同时设置请使用此方法)

Link copied to clipboard
abstract fun setFlags(flags: Int): Intent

设置标志位 (会覆盖之前的所有标志位)。

Link copied to clipboard
abstract fun setOrigin(origin: Intent)

设置原始对象

Link copied to clipboard
abstract fun setPackage(packageName: String): Intent

设置明确的应用程序包名。 用于限制 Intent 仅解析到该包中的组件。

Link copied to clipboard
abstract fun setType(type: String): Intent

设置 Intent 的 MIME 类型 (Type)。

Link copied to clipboard
abstract fun takeIf(predicate: (Intent) -> Boolean): ObjectWrapper<Intent>?

如果 ObjectWrapper 满足给定的 predicate,则返回 ObjectWrapper 本身,否则返回 null 包装在 ObjectWrapper? 中。

Link copied to clipboard
abstract fun takeUnless(predicate: (Intent) -> Boolean): ObjectWrapper<Intent>?

如果 ObjectWrapper 不满足给定的 predicate,则返回 ObjectWrapper 本身,否则返回 null 包装在 ObjectWrapper? 中。