- FLAG_GRANT_READ_URI_PERMISSION
/** * If set, the recipient of this Intent will be granted permission to * perform read operations on the URI in the Intent's data and any URIs * specified in its ClipData. When applying to an Intent's ClipData, * all URIs as well as recursive traversals through data or other ClipData * in Intent items will be granted; only the grant flags of the top-level * Intent are used. */ 临时访问读权限 intent的接受者将被授予 INTENT 数据uri 或者 在ClipData 上的读权限。
- FLAG_GRANT_WRITE_URI_PERMISSION
/** * If set, the recipient of this Intent will be granted permission to * perform write operations on the URI in the Intent's data and any URIs * specified in its ClipData. When applying to an Intent's ClipData, * all URIs as well as recursive traversals through data or other ClipData * in Intent items will be granted; only the grant flags of the top-level * Intent are used. */ 临时访问写权限 intent的接受者将被授予 INTENT 数据uri 或者 在ClipData 上的写权限。
3.FLAG_FROM_BACKGROUND
/** * Can be set by the caller to indicate that this Intent is coming from * a background operation, not from direct user interaction. */ 指明Intent来自后台操作 ,不是来自用户直接互动。
4.FLAG_DEBUG_LOG_RESOLUTION
/** * A flag you can enable for debugging: when set, log messages will be * printed during the resolution of this intent to show you what has * been found to create the final resolved list. */解析intent时打印log messages,展示创建最终的resolved list 找到的信息 。 比如有如下代码 : Intent intent = new Intent("android.provider.Telephony.SMS_RECEIVED"); intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION); sendBroadcast(intent); 将会按照优先级打印出系统所有注册"android.provider.Telephony.SMS_RECEIVED"的广播接收者。
5.FLAG_EXCLUDE_STOPPED_PACKAGES
/** * If set, this intent will not match any components in packages that * are currently stopped. If this is not set, then the default behavior * is to include such applications in the result. */如果设置 intent 将不会匹配处于stoped状态的组件,如果没设置,默认匹配 。
6.FLAG_INCLUDE_STOPPED_PACKAGES
/** * If set, this intent will always match any components in packages that * are currently stopped. This is the default behavior when * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these * flags are set, this one wins (it allows overriding of exclude for * places where the framework may automatically set the exclude flag). */ 如果设置,intent将匹配packages 内stopped状态的组件,也是intent的默认设置, 如果 exclude 跟 include 同时设置 ,include win!
- FLAG_GRANT_PERSISTABLE_URI_PERMISSION
/** * When combined with FLAG_GRANT_READ_URI_PERMISSION and/or * FLAG_GRANT_WRITE_URI_PERMISSION, the URI permission grant can be * persisted across device reboots until explicitly revoked with * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the * grant for possible persisting; the receiving application must call * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to * actually persist. * * @see ContentResolver#takePersistableUriPermission(Uri, int) * @see ContentResolver#releasePersistableUriPermission(Uri, int) * @see ContentResolver#getPersistedUriPermissions() * @see ContentResolver#getOutgoingPersistedUriPermissions() */ 区别于 FLAG_GRANT_READ_URI_PERMISSION 跟 FLAG_GRANT_WRITE_URI_PERMISSION, URI权限会持久存在即使重启,直到明确的用 revokeUriPermission(Uri, int) 撤销。 这个flag只提供可能持久授权。但是接收的应用必须调用ContentResolver的takePersistableUriPermission(Uri, int)方法实现 。
8.FLAG_GRANT_PREFIX_URI_PERMISSION
When combined with FLAG_GRANT_READ_URI_PERMISSION and/or FLAG_GRANT_WRITE_URI_PERMISSION, the URI permission grant applies to any URI that is a prefix match against the original granted URI. (Without this flag, the URI must match exactly for access to be granted.) Another URI is considered a prefix match only when scheme, authority, and all path segments defined by the prefix are an exact match. Uri 权限授予任何原始授权URI前缀匹配的URI。
9.FLAG_ACTIVITY_NO_HISTORY
/** * If set, the new activity is not kept in the history stack. As soon as * the user navigates away from it, the activity is finished. This may also * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory * noHistory} attribute. * * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()} * is never invoked when the current activity starts a new activity which * sets a result and finishes. * 如果设置,新的activity将不会保存在历史栈中。一旦 * 用户离开这个activity,它就会被finish掉。 * 也可以在manifest.xml中设置activity android:hoHistory属性设置。 *如果设置, OnActivityResult()方法将不会再被调用 。 * */
- FLAG_ACTIVITY_SINGLE_TOP
/** * If set, the activity will not be launched if it is already running * at the top of the history stack. * 如果设置了,如过Activity在栈顶将不会启动。 */
11.FLAG_ACTIVITY_NEW_TASK
/** * If set, this activity will become the start of a new task on this * history stack. A task (from the activity that started it to the * next task activity) defines an atomic group of activities that the * user can move to. Tasks can be moved to the foreground and background; * all of the activities inside of a particular task always remain in * the same order. See * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back * Stack</a> for more information about tasks. * * <p>This flag is generally used by activities that want * to present a "launcher" style behavior: they give the user a list of * separate things that can be done, which otherwise run completely * independently of the activity launching them. * * <p>When using this flag, if a task is already running for the activity * you are now starting, then a new activity will not be started; instead, * the current task will simply be brought to the front of the screen with * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag * to disable this behavior. * * <p>This flag can not be used when the caller is requesting a result from * the activity being launched. * 如果设置了,这个Activity将会成为新任务历史栈的开始 * 如果已经有一个task运行着邀请东的activity,将不会启动新的activity;当前任务栈最后状态 * 将会被展示在屏幕上 查看 FLAG_ACTIVITY_MULTIPLE_TASK ,关闭这一特性。 */
12.FLAG_ACTIVITY_MULTIPLE_TASK
/** * This flag is used to create a new task and launch an activity into it. * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT} * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would * search through existing tasks for ones matching this Intent. Only if no such * task is found would a new task be created. When paired with * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip * the search for a matching task and unconditionally start a new task. * 用来创建新的任务栈,启动activity。 * 总是跟 FLAG_ACTIVITY_NEW_DOCUMENT或FLAG_ACTIVITY_NEW_TASK一起用。 * 如果单独使用这两个,将从存在的任务栈中找寻匹配这个intent的。如果找不到, * 将会重新创建task。当匹配的时候,都是为了更改然后跳过找到匹配task的步骤,然后无条件的启动新的 * task * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this * flag unless you are implementing your own * top-level application launcher.</strong> * 不要轻易跟FLAG_ACTIVITY_NEW_TASK结合使用,除非你在实现自己的top-level application * launcher * Used in conjunction with * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the * behavior of bringing an existing task to the foreground. When set, * a new task is <em>always</em> started to host the Activity for the * Intent, regardless of whether there is already an existing task running * the same thing. * <p><strong>Because the default system does not include graphical task management, * you should not use this flag unless you provide some way for a user to * return back to the tasks you have launched.</strong> * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for * creating new document tasks. * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set. * 只设置这个flag而不与其他匹配将被忽略掉。 */
13.FLAG_ACTIVITY_CLEAR_TOP
/** * If set, and the activity being launched is already running in the * current task, then instead of launching a new instance of that activity, * all of the other activities on top of it will be closed and this Intent * will be delivered to the (now on top) old activity as a new Intent. * 当设置此标致,并且acitivity已经启动,那么不是启动一个activity新势力,所有其他顶部的activity * 都会关闭,这个intent将被交付到(现在顶部)老的activity 做为新的intent。 * <p>For example, consider a task consisting of the activities: A, B, C, D. * If D calls startActivity() with an Intent that resolves to the component * of activity B, then C and D will be finished and B receive the given * Intent, resulting in the stack now being: A, B. * 如果一个task由A,B,C,D组成,如果D调用startActivity(),跳到B, 然后C,D被finish掉,B * 接收新的intent ,结果栈中:A,B. * <p>The currently running instance of activity B in the above example will * either receive the new intent you are starting here in its * onNewIntent() method, or be itself finished and restarted with the * new intent. If it has declared its launch mode to be "multiple" (the * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in * the same intent, then it will be finished and re-created; for all other * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this * Intent will be delivered to the current instance's onNewIntent(). * 现在运行的B的实例或者在onNewIntent方法中接收你start的新intent,或者自己finish掉然后重启 * 一个新的intent。如果声明启动了启动模式是“multiple”(默认),并且你没有在这个intent中设置 * FLAG_ACTIVITY_SINGLE_TOP,就会finish掉然后重新创建。 * 其他的启动模式。或者FLAG_ACTIVITY_SINGLE_TOP被设置了,intent将会传送到当前实例的 * onNewIntent方法中。 * * <p>This launch mode can also be used to good effect in conjunction with * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity * of a task, it will bring any currently running instance of that task * to the foreground, and then clear it to its root state. This is * especially useful, for example, when launching an activity from the * notification manager. * 这个启动模式也可以跟FLAG_ACTIVITY_NEW_TASK结合使用:如果用来start 根activity,它将会 * 此task任意当前正在执行的实例bring to foreground,然后清除到跟状态。这非常有用,比如, * 当从notification manager启动一个activity。 */
14.FLAG_ACTIVITY_FORWARD_RESULT
/** * If set and this intent is being used to launch a new activity from an * existing one, then the reply target of the existing activity will be * transfered to the new activity. This way the new activity can call * {@link android.app.Activity#setResult} and have that result sent back to * the reply target of the original activity. * 如果设置,并且这个Intent用于从一个存在的Activity启动一个新的Activity,那么,这个作为答复目标 * 的Activity将会传到这个新的Activity中。这种方式下,新的Activity可以调用setResult(int), * 并且这个结果值将发送给那个作为答复目标的Activity。 */
15.FLAG_ACTIVITY_PREVIOUS_IS_TOP
/** * If set and this intent is being used to launch a new activity from an * existing one, the current activity will not be counted as the top * activity for deciding whether the new intent should be delivered to * the top instead of starting a new one. The previous activity will * be used as the top, with the assumption being that the current activity * will finish itself immediately. * 如果给Intent对象设置了这个标记,并且这个Intent对象被用于从一个既存的Activity中启动一个新的 * Activity,这个Activity不被看作决定是否传送新的intent到top而不是start新的, * 通常认为使用这个flag启动的Activity会被自己立即终止。 */
16.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
/** * If set, the new activity is not kept in the list of recently launched * activities. * 如果设置,新的Activity不会在最近启动的Activity的列表中保存。 */
17.FLAG_ACTIVITY_BROUGHT_TO_FRONT
/** * This flag is not normally set by application code, but set for you by * the system as described in the * {@link android.R.styleable#AndroidManifestActivity_launchMode * launchMode} documentation for the singleTask mode. * 通常不是通过应用程序代码设置,而是通过系统如launchMode singleTask模式。 */
18.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
/** * If set, and this activity is either being started in a new task or * bringing to the top an existing task, then it will be launched as * the front door of the task. This will result in the application of * any affinities needed to have that task in the proper state (either * moving activities to or from it), or simply resetting that task to * its initial state if needed. * FLAG_ACTIVITY_RESET_TASK_IF_NEEDED:如果设置该属性,并且 * 这个activity在一个新的task中正在被启动或者被带到一个已经存在 * 的task的顶部,这时这个activity将会被作为这个task的首个页面加 * 载。这将会导致拥有这个应用的affinities的task处于一个合适的状 * 态(移动activity到这个task或者activity从中移出),或者简单的 * 重置这个task到它的初始状态 */
19.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
/**
* This flag is not normally set by application code, but set for you by
* the system if this activity is being launched from history
* (longpress home key).
* 这个标记通常不由应用程序代码来设置,如果是从历史中启动这个Activity,系统就会设置这个标记。
* (长按home键)
*/
20.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
/**
* @deprecated As of API 21 this performs identically to
* {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
* api21过期,被FLAG_ACTIVITY_NEW_DOCUMENT代替。
*/
21.FLAG_ACTIVITY_NEW_DOCUMENT
/** * This flag is used to open a document into a new task rooted at the activity launched * by this Intent. Through the use of this flag, or its equivalent attribute, * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity * containing different documents will appear in the recent tasks list. * * <p>The use of the activity attribute form of this, * {@link android.R.attr#documentLaunchMode}, is * preferred over the Intent flag described here. The attribute form allows the * Activity to specify multiple document behavior for all launchers of the Activity * whereas using this flag requires each Intent that launches the Activity to specify it. * * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for * it is kept after the activity is finished is different than the use of * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if * this flag is being used to create a new recents entry, then by default that entry * will be removed once the activity is finished. You can modify this behavior with * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}. * * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the * equivalent of the Activity manifest specifying {@link * android.R.attr#documentLaunchMode}="intoExisting". When used with * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying * {@link android.R.attr#documentLaunchMode}="always". * * Refer to {@link android.R.attr#documentLaunchMode} for more information. * * @see android.R.attr#documentLaunchMode * @see #FLAG_ACTIVITY_MULTIPLE_TASK * 可以跟FLAG_ACTIVITY_MULTIPLE_TASK结合使用,当只用自己的时候相当于Manifast中 * android.R.attr.documentLaunchMode="intoExisting",当跟FLAG_ACTIVITY_MULTIPLE_TASK * 结合使用相当于 Manifast中android.R.attr.documentLaunchMode="always". */
22.FLAG_ACTIVITY_NO_USER_ACTION
/** * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint} * callback from occurring on the current frontmost activity before it is * paused as the newly-started activity is brought to the front. * * <p>Typically, an activity can rely on that callback to indicate that an * explicit user action has caused their activity to be moved out of the * foreground. The callback marks an appropriate point in the activity's * lifecycle for it to dismiss any notifications that it intends to display * "until the user has seen them," such as a blinking LED. * * <p>If an activity is ever started via any non-user-driven events such as * phone-call receipt or an alarm handler, this flag should be passed to {@link * Context#startActivity Context.startActivity}, ensuring that the pausing * activity does not think the user has acknowledged its notification. * onUserLeaveHint()作为activity周期的一部分,它在activity因为用户要跳转到别的activity而要退 * 到background时使用。比如,在用户按下Home键,它将被调用。比如有电话进来(不属于用户的选择),它 * 就不会被调用。 * 如果设置,作为新启动的Activity进入前台时,这个标志将在Activity暂停之前阻止从最前方的Activity * 回调的onUserLeaveHint()。典型的,一个Activity可以依赖这个回调指明显式的用户动作引起的 * Activity移出后台。这个回调在Activity的生命周期中标记一个合适的点,并关闭一些Notification。 * 如果一个Activity通过非用户驱动的事件,如来电或闹钟,启动的,这个标志也应该传递给 * Context.startActivity,保证暂停的Activity不认为用户已经知晓其Notification。 */
23.FLAG_ACTIVITY_REORDER_TO_FRONT
/** * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, * this flag will cause the launched activity to be brought to the front of its * task's history stack if it is already running. * 如果在intent里设置交给 startActivity(),这个flag会把已经运行过的acivity带到task历史 * 栈的顶端。 * * <p>For example, consider a task consisting of four activities: A, B, C, D. * If D calls startActivity() with an Intent that resolves to the component * of activity B, then B will be brought to the front of the history stack, * with this resulting order: A, C, D, B. * 例如,一个task由A,B,C,D四个activity组成,如果D哦赢携带这个flag的intent调用 * startActivity()打开B,那么B就会被带到历史栈的前部,结果是:A,C,D,B. * * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also * specified. * 如果LAG_ACTIVITY_CLEAR_TOP 被设置,那么FLAG_ACTIVITY_REORDER_TO_FRONT * 将被忽略。 */
24.FLAG_ACTIVITY_NO_ANIMATION
/** * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, * this flag will prevent the system from applying an activity transition * animation to go to the next activity state. This doesn't mean an * animation will never run -- if another activity change happens that doesn't * specify this flag before the activity started here is displayed, then * that transition will be used. This flag can be put to good use * when you are going to do a series of activity operations but the * animation seen by the user shouldn't be driven by the first activity * change but rather a later one. * 如果设置,将阻止系统get next activity的过渡动画。并不意味着一直不会有动画,--如果另一个 * activity 的变化发生没有在start activity 显示之前指定,会有过渡动画。 */
25.FLAG_ACTIVITY_CLEAR_TASK
/** * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, * this flag will cause any existing task that would be associated with the * activity to be cleared before the activity is started. That is, the activity * becomes the new root of an otherwise empty task, and any old activities * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}. * 如果在通过Context.startActivity()启动activity时为Intent设置了此标识,这个标识将导致: * 在此activity启动之前,任何与此activity相关联的task都会被清除。也就是说, * 此activity将变成一个空栈中新的最底端的activity,所有的旧activity都会被finish掉, * 这个标识仅仅和FLAG_ACTIVITY_NEW_TASK联合起来才能使用。 */
26.FLAG_ACTIVITY_TASK_ON_HOME
/** * If set in an Intent passed to {@link Context#startActivity Context.startActivity()}, * this flag will cause a newly launching task to be placed on top of the current * home activity task (if there is one). That is, pressing back from the task * will always return the user to home even if that was not the last activity they * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}. * 把当前新启动的任务置于Home任务之上,也就是按back键从这个任务返回的时候会回到home, * 即使这个不是他们最后看见的activity,注意这个标记必须和FLAG_ACTIVITY_NEW_TASK一起使用 */
27.FLAG_ACTIVITY_RETAIN_IN_RECENTS
/** * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will * have its entry in recent tasks removed when the user closes it (with back * or however else it may finish()). If you would like to instead allow the * document to be kept in recents so that it can be re-launched, you can use * this flag. When set and the task's activity is finished, the recents * entry will remain in the interface for the user to re-launch it, like a * recents entry for a top-level application. * 默认情况FLAG_ACTIVITY_NEW_DOCUMENT创建的document当用户关闭时之前tasks的entry会被remove * 掉,如果想保持在历史中一遍重新launch,就要用到这个flag.当使task的activity finish掉以后, * 历史entry将保持在界面以便用户重新打开类似顶级应用程序的历史。 * <p> * The receiving activity can override this request with * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling * {@link android.app.Activity#finishAndRemoveTask() * Activity.finishAndRemoveTask()}. * */
28.FLAG_RECEIVER_REGISTERED_ONLY
/** * If set, when sending a broadcast only registered receivers will be * called -- no BroadcastReceiver components will be launched. * 设置这个flag,发送广播只有动态注册才能调用,组件(xml 中定义action)不会被被launch. */
29.FLAG_RECEIVER_REPLACE_PENDING
/** * If set, when sending a broadcast the new broadcast will replace * any existing pending broadcast that matches it. Matching is defined * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning * true for the intents of the two broadcasts. When a match is found, * the new broadcast (and receivers associated with it) will replace the * existing one in the pending broadcast list, remaining at the same * position in the list. * 这个flag 将会将之前的Intent 替代掉。加了这个flag,在发送一系列的这样的Intent 之后, * 中间有些Intent 有可能在你还没有来得及处理的时候,就被替代掉了。 * * <p>This flag is most typically used with sticky broadcasts, which * only care about delivering the most recent values of the broadcast * to their receivers. */
30.FLAG_RECEIVER_FOREGROUND
/** * If set, when sending a broadcast the recipient is allowed to run at * foreground priority, with a shorter timeout interval. During normal * broadcasts the receivers are not automatically hoisted out of the * background priority class. * 当发送广播时,允许其接受者 在前台运行的拥有更高的优先级,更短的超时间隔。 */
31.FLAG_RECEIVER_NO_ABORT
/** * If this is an ordered broadcast, don't allow receivers to abort the broadcast. * They can still propagate results through to later receivers, but they can not * prevent later receivers from seeing the broadcast. * 如果是有序广播,不要允许接收者中断广播播。 * */
32.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
/** * If set, when sending a broadcast <i>before boot has completed</i> only * registered receivers will be called -- no BroadcastReceiver components * will be launched. Sticky intent state will be recorded properly even * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY} * is specified in the broadcast intent, this flag is unnecessary. * 在boot完成前发送广播,只有注册了的接收者才会被调用,xml中的无法launch. * * <p>This flag is only for use by system sevices as a convenience to * avoid having to implement a more complex mechanism around detection * of boot completion. * * @hide */
33.FLAG_RECEIVER_BOOT_UPGRADE
/** * Set when this broadcast is for a boot upgrade, a special mode that * allows the broadcast to be sent before the system is ready and launches * the app process with no providers running in it. * 系统更新广播,一个允许播放在系统准备好和launch app 进程之前发送的模式 * @hide */