|
| 1 | +package com.lenovo.video; |
| 2 | + |
| 3 | +import android.net.Uri; |
| 4 | +import android.support.v7.app.AppCompatActivity; |
| 5 | +import android.os.Bundle; |
| 6 | +import android.widget.MediaController; |
| 7 | +import android.widget.VideoView; |
| 8 | + |
| 9 | +import com.google.android.gms.appindexing.Action; |
| 10 | +import com.google.android.gms.appindexing.AppIndex; |
| 11 | +import com.google.android.gms.appindexing.Thing; |
| 12 | +import com.google.android.gms.common.api.GoogleApiClient; |
| 13 | + |
| 14 | +public class MainActivity extends AppCompatActivity { |
| 15 | + |
| 16 | + /** |
| 17 | + * ATTENTION: This was auto-generated to implement the App Indexing API. |
| 18 | + * See https://g.co/AppIndexing/AndroidStudio for more information. |
| 19 | + */ |
| 20 | + private GoogleApiClient client; |
| 21 | + |
| 22 | + @Override |
| 23 | + protected void onCreate(Bundle savedInstanceState) { |
| 24 | + super.onCreate(savedInstanceState); |
| 25 | + setContentView(R.layout.activity_main); |
| 26 | + |
| 27 | + VideoView videoView = (VideoView)findViewById(R.id.videoView); |
| 28 | + videoView.setVideoPath("android.resource://"+getPackageName()+"/"+R.raw.demovideo); |
| 29 | + MediaController mediaController = new MediaController(this); |
| 30 | + mediaController.setAnchorView(videoView); |
| 31 | + videoView.setMediaController(mediaController); |
| 32 | + videoView.start(); |
| 33 | + |
| 34 | + // ATTENTION: This was auto-generated to implement the App Indexing API. |
| 35 | + // See https://g.co/AppIndexing/AndroidStudio for more information. |
| 36 | + client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build(); |
| 37 | + } |
| 38 | + |
| 39 | + /** |
| 40 | + * ATTENTION: This was auto-generated to implement the App Indexing API. |
| 41 | + * See https://g.co/AppIndexing/AndroidStudio for more information. |
| 42 | + */ |
| 43 | + public Action getIndexApiAction() { |
| 44 | + Thing object = new Thing.Builder() |
| 45 | + .setName("Main Page") // TODO: Define a title for the content shown. |
| 46 | + // TODO: Make sure this auto-generated URL is correct. |
| 47 | + .setUrl(Uri.parse("http://[ENTER-YOUR-URL-HERE]")) |
| 48 | + .build(); |
| 49 | + return new Action.Builder(Action.TYPE_VIEW) |
| 50 | + .setObject(object) |
| 51 | + .setActionStatus(Action.STATUS_TYPE_COMPLETED) |
| 52 | + .build(); |
| 53 | + } |
| 54 | + |
| 55 | + @Override |
| 56 | + public void onStart() { |
| 57 | + super.onStart(); |
| 58 | + |
| 59 | + // ATTENTION: This was auto-generated to implement the App Indexing API. |
| 60 | + // See https://g.co/AppIndexing/AndroidStudio for more information. |
| 61 | + client.connect(); |
| 62 | + AppIndex.AppIndexApi.start(client, getIndexApiAction()); |
| 63 | + } |
| 64 | + |
| 65 | + @Override |
| 66 | + public void onStop() { |
| 67 | + super.onStop(); |
| 68 | + |
| 69 | + // ATTENTION: This was auto-generated to implement the App Indexing API. |
| 70 | + // See https://g.co/AppIndexing/AndroidStudio for more information. |
| 71 | + AppIndex.AppIndexApi.end(client, getIndexApiAction()); |
| 72 | + client.disconnect(); |
| 73 | + } |
| 74 | +} |
0 commit comments