现在的位置: 首页 > 综合 > 正文

public Intent setFlags (int flags) 解释

2019年05月20日 ⁄ 综合 ⁄ 共 1688字 ⁄ 字号 评论关闭

Intent android.content.Intent.setFlags(int flags)

 

public Intent setFlags (int flags)

Since: API Level 1

Set special flags controlling how this intent is handled. Most values here depend on the type of component being executed by the Intent, specifically the FLAG_ACTIVITY_* flags are all for use with Context.startActivity() and the FLAG_RECEIVER_* flags are
all for use with Context.sendBroadcast().

为了控制整个Intent的执行设置特定的标志。大多数的值依赖于通过Intent执行的所有类型组件,例如明确的有Context.startActivity()的FLAG_ACTIVITY_*标志和Context.sendBroadcast()的FLAG_RECEIVER_*标志。

See the Tasks and Back Stack documentation for important information on how some of these options impact the behavior of your application.

 

Parameters

flags  The desired flags.

 

Returns

Returns the same Intent object, for chaining multiple calls into a single statement.

See Also

getFlags()

addFlags(int)

FLAG_GRANT_READ_URI_PERMISSION

FLAG_GRANT_WRITE_URI_PERMISSION

FLAG_DEBUG_LOG_RESOLUTION

FLAG_FROM_BACKGROUND

FLAG_ACTIVITY_BROUGHT_TO_FRONT

FLAG_ACTIVITY_CLEAR_TASK

FLAG_ACTIVITY_CLEAR_TOP

FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET

FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS

FLAG_ACTIVITY_FORWARD_RESULT

FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY

FLAG_ACTIVITY_MULTIPLE_TASK

FLAG_ACTIVITY_NEW_TASK

FLAG_ACTIVITY_NO_ANIMATION

FLAG_ACTIVITY_NO_HISTORY

FLAG_ACTIVITY_NO_USER_ACTION

FLAG_ACTIVITY_PREVIOUS_IS_TOP

FLAG_ACTIVITY_RESET_TASK_IF_NEEDED

FLAG_ACTIVITY_REORDER_TO_FRONT

FLAG_ACTIVITY_SINGLE_TOP

FLAG_ACTIVITY_TASK_ON_HOME

FLAG_RECEIVER_REGISTERED_ONLY

例如:

// Pressing on the button brings the user back to our mood ring,

// as part of the api demos app.  Note the use of NEW_TASK here,

// since the notification display activity is run as a separate task.

Intent intent = new Intent(this, StatusBarNotifications.class);

intent.setAction(Intent.ACTION_MAIN);

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

startActivity(intent);

抱歉!评论已关闭.