标签:
将网站上的网页和智能手机相关联。已安装了相应软件的用户可以通过网站直接打开应用内容。
详细信息请参见官网https://developers.google.com/app-indexing/webmasters/app
官网上写的非常详细,可以看中文的。
HTML网页中要提供App Indexing的网址是http://example.com/淘宝店铺ID 淘宝店铺ID是不确定的值。
在AndroidMenifest.xml中声明Intent过滤器。
<activity android:name="com.example.android.GizmosActivity"
android:label="@string/title_gizmos" >
<intent-filter android:label="@string/filter_title_viewgizmos">
<action android:name="android.intent.action.VIEW" />
<!-- 可以获取包含 "http://example.com/gizmos" 开头的url -->
<data android:scheme="http"
android:host=".*"
android:pathPrefix="/gizmos" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>adb shell am start -a android.intent.action.VIEW -d "http://example.com/g23422" com.example.android或者在HTML网页上添加:
<a href="intent://example.com/gizmos#Intent;scheme=http;package=com.example.android;end;">
http://example.com/g23422
</a>
在https://developers.google.com/app-indexing/webmasters/test中输入【android-app://packageName/scheme/host/pathPrefix】。详情请参考下图:
</pre></p><p><span style="font-size:10px;">方法如下:</span><pre name="code" class="java"> public boolean isCallByAppIndexing(Activity activity) {
Intent intent = activity.getIntent();
Uri uri = intent.getData();
if (uri != null) {
String scheme = uri.getScheme();
String host = uri.getHost();
if (scheme != null && scheme.equals("http")) {
if (host != null && host.equals("example.com")) {
return true;
}
}
}
return false;
} public String getShopId(Activity activity) {
String shopId = null;
Uri uri = activity.getIntent().getData();
if (uri != null) {
List<String> list = uri.getPathSegments();
shopId = (list == null ? null : list.get(0));
}
return shopId;
}版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/liucaoye/article/details/48054167