11月の初旬頃、アナウンスされた「App Indexing」。
Google検索での検索結果画面に、ダイレクトでアプリを起動できるボタンが表示されるようになるというやつ。

App Indexing for Google Search — Google Developers 
今はまだ、日本では、いや、USでも、公開されてないような雰囲気ですが。
まずは登録すればUSから利用できるようになるとか。

App Indexing - Expression of Interest 
利用の手順としては、公開サイトやそのサイトマップに「おれおれスキーム」なURLを埋め込んでおきなさい、と。
きっとクローラが持っていくのでしょう。

そして、アプリ側には、ブラウザ上のクリックに反応する <intent-filter> を記述しておきなさい、以下2つのURIに対してのクリックに反応するよ、と。
・ http://www.example.com/gizmos 
・ example://gizmos
<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <!-- Accepts URIs that begin with "example://gizmos" -->
    <data android:scheme="example"
          android:host="gizmos" />
    <!-- Accepts URIs that begin with "http://www.example.com/gizmos" -->
    <data android:scheme="http"
          android:host="www.example.com"
          android:pathPrefix="gizmos" />
</intent-filter>
この記述をアプリに適用したら、以下のコマンドで試してみたらいいらしい。
$ adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.example.android
で、やってみたら、
両方ダメなんですけど。
$ adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.example.android
Starting: Intent { act=android.intent.action.VIEW dat=example://gizmos pkg=com.example.android }
Error: Activity not started, unable to resolve Intent { act=android.intent.action.VIEW dat=example://gizmos flg=0x10000000 pkg=com.example.android }
$ adb shell am start -W -a android.intent.action.VIEW -d "http://www.example.com/gizmos" com.example.android
Starting: Intent { act=android.intent.action.VIEW dat=http://www.example.com/gizmos pkg=com.example.android }
Error: Activity not started, unable to resolve Intent { act=android.intent.action.VIEW dat=http://www.example.com/gizmos flg=0x10000000 pkg=com.example.android }
<data> 部分の属性の優先順位とか、未設定の場合のデフォルトの使用とか、なんかあるのかな。
あと pathPrefix の「/(スラッシュ)」も。
すこし変更、2つに分けて、
<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <!-- Accepts URIs that begin with "example://gizmos" -->
    <data android:scheme="example"
          android:host="gizmos" />
</intent-filter>
<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
    <data android:scheme="http"
          android:host="www.example.com"
          android:pathPrefix="/gizmos" />
</intent-filter>
で、再度コマンドラインから、
$ adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.example.android
Starting: Intent { act=android.intent.action.VIEW dat=example://gizmos pkg=com.example.android }
Status: ok
Activity: com.example.android/.MainActivity
ThisTime: 77
TotalTime: 77
Complete
$ adb shell am start -W -a android.intent.action.VIEW -d "http://www.example.com/gizmos" com.example.android
Starting: Intent { act=android.intent.action.VIEW dat=http://www.example.com/gizmos pkg=com.example.android }
Status: ok
Activity: com.example.android/.MainActivity
ThisTime: 80
TotalTime: 80
Complete
となっていける。ブラウザリンクからもアプリが起動できたりするけど、はたして。。。
すこし思うのは、そのアプリを端末にインストールしてない場合は、ブラウザ上でどう表示されるのか。
上記WEB設定により、クローラが持っていった情報には「アプリのID」は含まれているので、GooglePlayStore のURLを知らないわけではないけども。。。
App Indexing for Google Search — Google Developers 
関連ワード: Android・Google・アプリ・ニュース・便利な設定・評判・速報・開発・AndroidManifest.xml・app indexing・appindexing・intent
 
		 
          