Intent学習ノート

2531 ワード

An  Intent  object is a bundle of information(a bundle:バンドル)には、2つの部分の情報が含まれています.
このintentのコンポーネントが興味を持っている情報、例えばaction、dataを受信します.
Androidシステムに興味のある情報、例えばcategory of component that should handle the intentとinstructions on how to launch a target activity;
 
Intentには主に以下の内容が含まれています.
1、Component Name
このintentのコンポーネントの名前を処理します.このデータドメインはComponentNameオブジェクトで、コンポーネント名はオプションです.
2、Action
A string naming the action to be performed — or, in the case of broadcast intents, the action that took place and is being reported.
Those you invent should include the application package as a prefix — for example: "com.example.project.SHOW_COLOR ".
大きく、actionはintentの他の部分がどのように構成されているか、特にdataおよびextraデータドメインを決定する.したがって、できるだけ正確なactionの名前を使用し、他のデータドメインと緊密に結合し、単純に1つのactionデータドメインだけを使用するのではなく、Intentオブジェクト内の完全なプロトコル、すなわちできるだけ多くのデータドメインまたはすべてのデータドメインを定義します.
3、Data
the URL of the data to be acted on;
the MIME type of that data;
アクションによって異なるデータ仕様、例えばACTION_EDIT actionは、データドメインが編集されたドキュメントのURIであり、actionがACTION_である場合CALL、データドメインはtel:のURIで、ダイヤルする電話番号が含まれています.そして、ACTION_VIEW actionのデータドメインはhttp:URIであり、受信したactivityはURIに対応するデータをダウンロードして表示する.
コンポーネントと処理可能なIntentをマッチングする場合、URIに加えてデータ型も重要です.たとえば、コンポーネントがimageデータを表示できる場合、オーディオファイルを表示するために呼び出すべきではありません.
多くの場合、データ型は、content:URIがデバイス上のデータを表し、content providerによって制御されるため、URI、特にcontent:URIを推測することができる.ただし、タイプ表示の設定も可能であり、setData()関数はURIとしてのみデータを指定し、setType()はMIMEタイプのみを指定し、setData AndTypeはURIとMIMEタイプを同時に指定する.
4、Category
A string containing additional information about the kind of component that should handle the intent.  付加情報は、このintentを処理するコンポーネントの種類についてです.
Any number of category descriptions can be placed in an Intent object.任意の数のcategory記述.
5、Extras
キー値ペア
Just as some actions are paired with particular kinds of data URIs, some are paired with particular extras.
あるactionsはデータURIsを組み合わせて、ある組み合わせは特殊なextrasです.
6、Flags
Flags of various sorts.Many instruct指示、命令the Android system how to launch an activity(for example,which task the activity should belong to)and how to treat it after it's launched(for example,wheter it belongs in the list of recent activities).All these flags are defined in the Intent class.