| package com.example.creation; |
| |
| import a.Action; |
| import a.AppIndex; |
| import a.GoogleApiClient; |
| import a.Thing; |
| |
| import android.app.Activity; |
| import android.net.Uri; |
| import android.os.Bundle; |
| |
| public class MainActivity extends Activity { |
| |
| /** |
| * ATTENTION: This was auto-generated to implement the App Indexing API. |
| * See https://g.co/AppIndexing/AndroidStudio for more information. |
| */ |
| private com.google.android.gms.common.api.GoogleApiClient client; |
| |
| @Override |
| protected void onCreate(Bundle savedInstanceState) { |
| super.onCreate(savedInstanceState); |
| // ATTENTION: This was auto-generated to implement the App Indexing API. |
| // See https://g.co/AppIndexing/AndroidStudio for more information. |
| client = new com.google.android.gms.common.api.GoogleApiClient.Builder(this).addApi(com.google.android.gms.appindexing.AppIndex.API).build(); |
| } |
| |
| /** |
| * ATTENTION: This was auto-generated to implement the App Indexing API. |
| * See https://g.co/AppIndexing/AndroidStudio for more information. |
| */ |
| public com.google.android.gms.appindexing.Action getIndexApiAction() { |
| com.google.android.gms.appindexing.Thing object = new com.google.android.gms.appindexing.Thing.Builder() |
| .setName("Main Page") // TODO: Define a title for the content shown. |
| // TODO: Make sure this auto-generated URL is correct. |
| .setUrl(Uri.parse("http://www.example.com/main")) |
| .build(); |
| return new com.google.android.gms.appindexing.Action.Builder(com.google.android.gms.appindexing.Action.TYPE_VIEW) |
| .setObject(object) |
| .setActionStatus(com.google.android.gms.appindexing.Action.STATUS_TYPE_COMPLETED) |
| .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. |
| client.connect(); |
| com.google.android.gms.appindexing.AppIndex.AppIndexApi.start(client, getIndexApiAction()); |
| } |
| |
| @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. |
| com.google.android.gms.appindexing.AppIndex.AppIndexApi.end(client, getIndexApiAction()); |
| client.disconnect(); |
| } |
| } |