gpt4 book ai didi

android - 如何将带有描述和预览的我的应用程序内容添加到 Google 搜索结果中?

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:49:04 28 4
gpt4 key购买 nike

我找到这篇文章:A new way to search for content in your apps我真的很高兴有这个机会。我想在 google 搜索结果中显示我的应用程序内容,如下所示:

Google In Apps Search

但这篇文章没有任何关于如何在您的应用中实现此功能的信息。

我在我的应用程序中使用 App Indexing API,如文章所述:

这是我的代码:

...
private GoogleApiClient mClient;

@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ac_main);
mClient = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}

public Action getAction() {
Thing object = new Thing.Builder()
.setName("Test Content")
.setDescription("Test Description")
.setUrl(Uri.parse("myapp://com.example/"))
.build();

return new Action.Builder(Action.TYPE_VIEW).setObject(object)
.setActionStatus(Action.STATUS_TYPE_COMPLETED)
.build();
}

@Override
public void onStart() {
super.onStart();
mClient.connect();
AppIndex.AppIndexApi.start(mClient, getAction());
}

@Override
public void onStop() {
AppIndex.AppIndexApi.end(mClient, getAction());
mClient.disconnect();
super.onStop();
}
...

这是结果:

Search result

Google 显示了我的应用程序的测试内容,但没有描述和预览图像。 有什么方法可以在 Google 搜索结果中添加描述和预览图片吗?(例如 Youtube 或 Twitter)

最佳答案

试试这个

     Thing object = new Thing.Builder()
.setName("Test Content")
.setDescription("Test Description")
.setUrl(Uri.parse("myapp://com.example/"))
//.put("image","YourImageUrlHere")
//I took one android logo url
.put("image","http://www.logospike.com/wp-content/uploads/2015/10/Android_Logo_04.png")
.build();

该图像可以是 ImageObject 或图像 Url。

您正在使用 Action.VIEW_TYPE。

https://developers.google.com/android/reference/com/google/android/gms/appindexing/Action#TYPE_VIEW

根据文档,

公共(public)静态最终字符串 TYPE_VIEW

消费静态视觉内容的行为。常数值:“https://schema.org/ViewAction

引用https://schema.org/ViewAction您可以在“Thing 的属性”下找到“图像”对象。

希望对你有所帮助。

关于android - 如何将带有描述和预览的我的应用程序内容添加到 Google 搜索结果中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39413123/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com