Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How add my application content with description and preview to Google search results?

I found this article: A new way to search for content in your apps and I'm really excited for this opportunity. I want to show my application content in google search results, like this:

Google In Apps Search

But this article doesn't have any information about how to implement this features in your app.

I use App Indexing API in my application, as described in articles:

This is my code:

...
  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();
  }
...

And this is result:

Search result

Google show my application's Test Content but without description and preview image. Is there any ways to add description and preview image in Google Search Results? (like Youtube or Twitter)

like image 535
ArtKorchagin Avatar asked Sep 09 '16 13:09

ArtKorchagin


1 Answers

Try this

     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();

That Image can be ImageObject or a Image Url.

You are using Action.VIEW_TYPE.

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

As per the documentation,

public static final String TYPE_VIEW

The act of consuming static visual content. Constant Value: "https://schema.org/ViewAction"

Refer https://schema.org/ViewAction you can find "image" object under "Properties from Thing".

Hope it will help you.

like image 66
Ajith Pandian Avatar answered Oct 12 '22 22:10

Ajith Pandian