Intent flags

Activity起動時、期待する動作を実現する為に、以下のフラグを設定する場合がある。


Intent i = new Intent();
i.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
startActivity( i );

http://developer.android.com/reference/android/content/Intent.html
# Flags






















FLAGSDETAILS
FLAG_ACTIVITY_BROUGHT_TO_FRONTThis flag is not normally set by application code, but set for you by the system as described in the launchMode documentation for the singleTask mode.
アプリケーション・コードでは通常セットされず、シングルタスクモード(ラウンチモードのひとつ)でシステムに設定される
FLAG_ACTIVITY_CLEAR_TOPIf 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.
FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESETIf set, this marks a point in the task's activity stack that should be cleared when the task is reset.
FLAG_ACTIVITY_EXCLUDE_FROM_RECENTSIf set, the new activity is not kept in the list of recently launched activities.
新しいActivityは最近起動されたActivityリストに保存されない。”最近起動されたActivityリスト”は「HOME」キーを長押下すると表示できる
FLAG_ACTIVITY_FORWARD_RESULTIf 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.
既存のActivityから新しいActivityが起動される場合にこのフラグを使用すると、正常終了であれば、既存のActivityに伝えられた結果を新しいActivityに伝える
FLAG_ACTIVITY_LAUNCHED_FROM_HISTORYThis 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が起動された時に、システムによって設定される
FLAG_ACTIVITY_MULTIPLE_TASKDo not use this flag unless you are implementing your own top-level application launcher.
「FLAG_ACTIVITY_NEW_TASK」と共に使用され、既に起動していたとしても新しくActivityを起動する。また、独自のトップレベルのアプリケーション・ランチャーを実装していなければ、このフラグを使うことはできない
FLAG_ACTIVITY_NEW_TASKIf set, this activity will become the start of a new task on this history stack.
履歴スタック上で新しいタスクとしてActivityを起動する
FLAG_ACTIVITY_NO_HISTORYIf set, the new activity is not kept in the history stack.
システムの起動履歴に記録せずにActivityを起動する
FLAG_ACTIVITY_NO_USER_ACTIONIf set, this flag will prevent the normal onUserLeaveHint() callback from occurring on the current frontmost activity before it is paused as the newly-started activity is brought to the front.
FLAG_ACTIVITY_PREVIOUS_IS_TOPIf 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.
既存のActivityから新しいActivityが起動される場合にこのフラグを使用すると、既存のActivityがすぐに終了することを前提として、新しいActivityがトップとして扱われる
FLAG_ACTIVITY_REORDER_TO_FRONTIf set in an Intent passed to 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.
FLAG_ACTIVITY_RESET_TASK_IF_NEEDEDIf 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_SINGLE_TOPIf set, the activity will not be launched if it is already running at the top of the history stack.
起動したActivityが既に履歴スタックの最上部で動作している場合は、Activityを起動しないようにシステムに伝える(onNewIntentコールバックが既に起動しているActivityに通知される)
FLAG_DEBUG_LOG_RESOLUTIONA 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.
デバッグ用に使用され、インテントの処理中にログを生成する
FLAG_FROM_BACKGROUNDCan be set by the caller to indicate that this Intent is coming from a background operation, not from direct user interaction.
このインテントがユーザインタラクション以外のバックグラウンドから送られたことを示すために設定する
FLAG_GRANT_READ_URI_PERMISSIONIf set, the recipient of this Intent will be granted permission to perform read operations on the Uri in the Intent's data.
インテントの受信者は、指定された「URI」のREAD権限を与えられる
FLAG_GRANT_WRITE_URI_PERMISSIONIf set, the recipient of this Intent will be granted permission to perform write operations on the Uri in the Intent's data.
インテントの受信者は、指定された「URI」のWRITE権限を与えられる
FLAG_RECEIVER_REGISTERED_ONLYIf set, when sending a broadcast only registered receivers will be called -- no BroadcastReceiver components will be launched.
登録されたレシーバにのみブロードキャストを送信したとき、ブロードキャスト・レシーバは起動されない
FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOTIf set, when sending a broadcast before boot has completed 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 FLAG_RECEIVER_REGISTERED_ONLY is specified in the broadcast intent, this flag is unnecessary.