インテントフィルターの設定
インテントフィルターとは
インテントフィルタ(IntentFilter)とは、アクティビティやサービスが取り扱うことができるインテントの設定。 インテントフィルターを用いることで、設定したインテントにのみを取り扱うように定義ができる。
インテントを受け取りたいActivityにセットする
- 構文
<data android:host="文字列" android:mimeType="文字列" android:path="文字列" android:pathPattern="文字列" android:pathPrefix="文字列" android:scheme="文字列" />
URLを属性を用いて特定する
http://tomo.jp/12345
→scheme://host/pathまたはpathPatternまたはpathPrefix
属性について
例
AndroidManifest.xml
<activity android:name=".ui.activity.SampleActivity"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="http" android:host="tomo.jp" android:path="/" /> <data android:scheme="http" android:host="abcabc" android:pathPattern="/tomo/.*/"/> <data android:scheme="http" android:host="tomo.jp" android:pathPrefix="moka/" /> </intent-filter> </activity>
上記の場合、インテントを受け取れるURIは、
* http: //tomo.jp/
* http: //abcabc/tomo/./
* http: //tomo.jp/moka/.
詳細については下記参照。
http://www.techdoctranslator.com/android/guide/manifest/data-element