背景
我今天刚刚创建了一个新的POC (关于活动转换,但这不是主题),我注意到在main活动的"onCreate“方法中写了一行新行:
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
mClient = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
以及更多内容:
@Override
public void onStart() {
super.onStart();
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
mClient.connect();
Action viewAction = Action.newAction(
Action.TYPE_VIEW, // TODO: choose an action type.
"SinglePhotoViewer Page", // TODO: Define a title for the content shown.
// TODO: If you have web page content that matches this app activity's content,
// make sure this auto-generated web page URL is correct.
// Otherwise, set the URL to null.
Uri.parse("http://host/path"),
// TODO: Make sure this auto-generated app deep link URI is correct.
Uri.parse("android-app://com.example.user.transitionstest/http/host/path")
);
AppIndex.AppIndexApi.start(mClient, viewAction);
}
@Override
public void onStop() {
super.onStop();
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
Action viewAction = Action.newAction(
Action.TYPE_VIEW, // TODO: choose an action type.
"SinglePhotoViewer Page", // TODO: Define a title for the content shown.
// TODO: If you have web page content that matches this app activity's content,
// make sure this auto-generated web page URL is correct.
// Otherwise, set the URL to null.
Uri.parse("http://host/path"),
// TODO: Make sure this auto-generated app deep link URI is correct.
Uri.parse("android-app://com.example.user.transitionstest/http/host/path")
);
AppIndex.AppIndexApi.end(mClient, viewAction);
mClient.disconnect();
}
这是添加到清单中的:
<!-- ATTENTION: This was auto-generated to add Google Play services to your project for
App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information. -->
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
问题所在
看着写好的网站,我还是不明白它是什么。
我猜是如何使用它的,但我不明白它是如何工作的。
另外,奇怪的是,我创建的任何其他新项目都不会显示这行新代码
问题
我的猜测是,根据我在网站上读到的和看到的,这只适用于可以执行某种搜索的应用程序,这样Google就可以向用户显示以前的查询和更快的结果。
https://stackoverflow.com/questions/34481370
复制相似问题