I am working on integrating google app indexing for my android news application. I have gone through the official documentation and code-labs example. They create an object for the index api using the following code.
Thing object = new Thing.Builder()
.setName(mTitle)
.setUrl(mUrl)
.build();
While exploring I came to know that Thing.Builder
has three more setters i.e setId()
, setType()
and setDescription()
,
While setDescription()
is self explanatory, I couldn't understand the difference between setId()
and setUrl()
methods,
From the documentation,
public Thing.Builder setId (String id)
Sets the optional web URL of the content.`
,
public Thing.Builder setUrl (Uri url)
Sets the URL of the content in the app.
But I am not able to figure out the difference between the two. Both these methods seems to be setting the url of the content. For my purpose, every news article has a unique url. So I should set that url to which method?
Also what is the use of getType method? Is it for setting "http" or "https"
public Thing.Builder setType (String type)
Sets the schema.org type of the content.
Based on this doc: https://developers.google.com/android/reference/com/google/android/gms/appindexing/Thing.Builder.html#public-methods
id: The equivalent web url for the content.
type: The schema.org type of the content.
Type is the action type: https://developers.google.com/android/reference/com/google/android/gms/appindexing/Action#nested-class-summary
url: The app URI of the content, must not be null. The URI must either be an HTTP(S) URL, or use the App Indexing format. In either case, the app calling this method needs to handle corresponding incoming Intents and take users to that content.
Cheers,
MB