IntentFlags

interface IntentFlags

Intent 标志位接口,定义了 Android Intent 中常用的 FLAG 常量。

Author

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

Functions

Link copied to clipboard
abstract fun getActivityClearTask(): Int

如果设置,主要用于与 getActivityNewTask 结合使用。 它会导致在该 Activity 启动之前,与该 Activity 关联的任务被完全清空。 也就是说,新 Activity 将成为空任务的根 Activity,旧的 Activity 都被结束。 对应: android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK

Link copied to clipboard
abstract fun getActivityClearTop(): Int

如果设置,并且该 Activity 已经在当前任务中运行,则会销毁该 Activity 上面的所有 Activity, 使该 Activity 位于栈顶,并调用其 android.app.Activity.onNewIntent 方法。 对应: android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP

Link copied to clipboard

如果设置,新的 Activity 不会保存在最近启动的 Activity 列表(最近任务列表)中。 对应: android.content.Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS

Link copied to clipboard

如果设置,并且该 Activity 是从现有 Activity 启动的,则该 Activity 的结果(setResult) 将返回给现有 Activity 的调用者,而不是现有 Activity 本身。 对应: android.content.Intent.FLAG_ACTIVITY_FORWARD_RESULT

Link copied to clipboard

如果设置,系统通常在从历史记录(长按 Home 键)启动 Activity 时设置此标志。 应用程序通常不需要手动设置。 对应: android.content.Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY

Link copied to clipboard

如果设置,在解析 Intent 时不仅要匹配内部应用,还要匹配外部存储上的应用。 对应: android.content.Intent.FLAG_ACTIVITY_MATCH_EXTERNAL

Link copied to clipboard

用于告诉系统不要创建新任务,即使使用了 getActivityNewTask。 只有在必要时才使用此标志,通常由系统处理。 对应: android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK

Link copied to clipboard
abstract fun getActivityNewDocument(): Int

用于创建文档类型的 Activity。 此标志将为该 Activity 打开一个新文档,将其放入最近任务列表中。 对应: android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT

Link copied to clipboard
abstract fun getActivityNewTask(): Int

如果设置,这个 Activity 会成为历史栈中一个新任务的开始。 通常用于从 Service 或 BroadcastReceiver 启动 Activity。 对应: android.content.Intent.FLAG_ACTIVITY_NEW_TASK

Link copied to clipboard
abstract fun getActivityNoAnimation(): Int

如果设置,并在 Intent 中包含数据,则系统会在设备上查找匹配的 .obb 文件并将其挂载。 (自 Android API 21 起弃用,但在某些旧系统中可能仍有意义) 对应: android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION

Link copied to clipboard
abstract fun getActivityNoHistory(): Int

如果设置,新的 Activity 将不会保留在历史栈中。一旦用户离开它,它就会被销毁。 对应: android.content.Intent.FLAG_ACTIVITY_NO_HISTORY

Link copied to clipboard

如果设置,当 Activity 暂停时,防止系统调用 android.app.Activity.onUserLeaveHint。 通常用于由非用户操作(如电话呼入)触发的中断。 对应: android.content.Intent.FLAG_ACTIVITY_NO_USER_ACTION

Link copied to clipboard

如果设置,该 Activity 将被视为前一个 Activity 的顶级 Activity, 即使它实际上并不是。通常用于确定 Activity 转换动画。 对应: android.content.Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP

Link copied to clipboard

如果设置,如果该 Activity 已经运行,它将被移动到历史栈的前面(顶部)。 对应: android.content.Intent.FLAG_ACTIVITY_REORDER_TO_FRONT

Link copied to clipboard

如果设置,并且任务被重置(例如用户从 Home 切换回应用), 则需要在该 Activity 完成之前重置任务。 对应: android.content.Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED

Link copied to clipboard
abstract fun getActivitySingleTop(): Int

如果设置,当这个 Activity 位于历史栈顶时,不再启动一个新的实例,而是复用栈顶的实例, 并调用其 android.app.Activity.onNewIntent 方法。 对应: android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP

Link copied to clipboard
abstract fun getActivityTaskOnHome(): Int

如果设置,此 Activity 将在 Home Activity 上启动(即按下 Back 键将返回 Home)。 需要与 getActivityNewTask 配合使用。 对应: android.content.Intent.FLAG_ACTIVITY_TASK_ON_HOME

Link copied to clipboard
abstract fun getDebugLogResolution(): Int

启用调试日志记录以进行 Intent 解析。 对应: android.content.Intent.FLAG_DEBUG_LOG_RESOLUTION

Link copied to clipboard

如果设置,处于停止状态(force-stop)的应用将不会收到此广播。 对应: android.content.Intent.FLAG_EXCLUDE_STOPPED_PACKAGES

Link copied to clipboard
abstract fun getFromBackground(): Int

指示 Intent 来自后台操作。 对应: android.content.Intent.FLAG_FROM_BACKGROUND

Link copied to clipboard

当与 getGrantReadUriPermissiongetGrantWriteUriPermission 一起使用时, 权限授予将扩展到 URI 的前缀匹配。 对应: android.content.Intent.FLAG_GRANT_PREFIX_URI_PERMISSION

Link copied to clipboard

如果设置,接收该 Intent 的接收者将被授予对 Intent 数据中的 URI 执行读取操作的权限。 对应: android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION

Link copied to clipboard

如果设置,接收该 Intent 的接收者将被授予对 Intent 数据中的 URI 执行写入操作的权限。 对应: android.content.Intent.FLAG_GRANT_WRITE_URI_PERMISSION

Link copied to clipboard

如果设置,即使应用处于停止状态(force-stop),也会尝试包含该应用作为接收者。 对应: android.content.Intent.FLAG_INCLUDE_STOPPED_PACKAGES

Link copied to clipboard
abstract fun getReceiverForeground(): Int

如果设置,广播接收器将在前台运行,拥有更高的优先级,不太可能被系统杀死。 对应: android.content.Intent.FLAG_RECEIVER_FOREGROUND

Link copied to clipboard
abstract fun getReceiverNoAbort(): Int

如果设置,这就是一个受保护的广播,接收者不能通过 android.content.BroadcastReceiver.abortBroadcast 中止它。 对应: android.content.Intent.FLAG_RECEIVER_NO_ABORT

Link copied to clipboard

如果设置,广播只会发送给动态注册的接收器(通过 android.content.Context.registerReceiver), 而不会发送给在 AndroidManifest.xml 中声明的接收器。 对应: android.content.Intent.FLAG_RECEIVER_REGISTERED_ONLY

Link copied to clipboard

如果设置,如果系统中已有相同的挂起广播,则新的广播将替换旧的。 对应: android.content.Intent.FLAG_RECEIVER_REPLACE_PENDING

Link copied to clipboard

如果设置,广播将对免安装应用(Instant Apps)可见。 对应: android.content.Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS