Background
I just created a new POC today (about activity transitions, but this isn't the topic), and I've noticed a new line being written in the "onCreate" method of the main activty:
// 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();
And more:
@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();
}
and this was added to the manifest:
<!-- 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"/>
The problem
Looking at the website that was written, I still don't get what it is.
I guess this is how to use it, but I don't get how it all works.
Also, weird thing is that any other new project that I create doesn't show this new line of code
The questions
- What is this? What does it do?
- What should I do with it?
- Are there any customizations for it? Any recommendations?
- On which cases does this line of code get generated? I didn't notice how and when it gets created...
My guess, according to what I've read and seen on the website, is that this is only used for apps that can perform some sort of searching, so that Google could show the user previous queries and faster results.