title: Android: How to go back to previous screen after playing YouTube video
body: <p>My app plays a specific YouTube video when a button is clicked.
  After watching the video I want the YouTube video player to close and the app to go back to the previous screen instead of displaying more suggested videos.
  Here is the code I have, how do I do that?</p>
  
  <pre><code>package com.newapp;
  import android.os.Bundle;
  import android.widget.Toast;
  import com.google.android.youtube.player.YouTubeBaseActivity;
  import com.google.android.youtube.player.YouTubeInitializationResult;
  import com.google.android.youtube.player.YouTubePlayer;
  import com.google.android.youtube.player.YouTubePlayer.Provider;
  import com.google.android.youtube.player.YouTubePlayerView;
  
  public class Level_1_Training extends YouTubeBaseActivity implements
          YouTubePlayer.OnInitializedListener{
  
      public static final String API_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
      public static final String VIDEO_ID = "XXXXXXXXXXXXXXX";
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_video);
  
          YouTubePlayerView youTubePlayerView = (YouTubePlayerView)findViewById(R.id.youtubeplayerview);
          youTubePlayerView.initialize(API_KEY, this);
      }
  
      @Override
      public void onInitializationFailure(Provider provider,
                                          YouTubeInitializationResult result) {
          Toast.makeText(getApplicationContext(),
                  "onInitializationFailure()",
                  Toast.LENGTH_LONG).show();
      }
  
  
      @Override
      public void onInitializationSuccess(Provider provider, YouTubePlayer player,
                                          boolean wasRestored) {
          player.setPlayerStyle(YouTubePlayer.PlayerStyle.MINIMAL);
          if (!wasRestored) {
  
          player.loadVideo(VIDEO_ID);
  
          }
      }
  
  
  
  }
  </code></pre>