title: VideoView FullScreen when Click on FullScreen Icon
body: <p>I am creating android application. I am successful to add mediacontroller and add small icon in the videoview to fullscreen the video to LandScape mode when click on fullscreen icon. But i am having error when click on FullScreen Icon. Here is my Code.</p>
  
  <p><strong>Details Activity :</strong> </p>
  
  <pre><code>import android.content.Intent;
  import android.media.MediaPlayer;
  import android.net.Uri;
  import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import android.util.Log;
  import android.view.View;
  import android.view.Window;
  import android.view.WindowManager;
  import android.widget.ImageButton;
  import android.widget.ImageView;
  import android.widget.MediaController;
  import android.widget.TextView;
  import android.widget.VideoView;
  
  import org.w3c.dom.Text;
  
  public class DetailsActivity extends AppCompatActivity {
      VideoView vidView;
      TextView description;
      ImageButton mPlayButton;
      TextView movienamedetails;
      TextView movieCategory;
      ImageView imageCover;
      TextView movieDuration;
      TextView movieYear;
      private static final String TAG = "MainActivity";
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          requestWindowFeature(Window.FEATURE_NO_TITLE);
          getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                  WindowManager.LayoutParams.FLAG_FULLSCREEN);
          setContentView(R.layout.activity_details);
          vidView=(VideoView) findViewById(R.id.myVideo);
          description=(TextView)findViewById(R.id.tv_description_detail);
          imageCover=(ImageView)findViewById(R.id.imagecoverdetails);
          movienamedetails = (TextView) findViewById(R.id.movienamedetails);
          movieCategory = (TextView) findViewById(R.id.moviecategorty);
          movieDuration = (TextView) findViewById(R.id.movieDuration);
          movieYear = (TextView) findViewById(R.id.moviedate);
  
          String fullScreen =  getIntent().getStringExtra("fullScreenInd");
          if("y".equals(fullScreen)){
              getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                      WindowManager.LayoutParams.FLAG_FULLSCREEN);
              getSupportActionBar().hide();
          }
          Intent intent = getIntent();
  
          String desc_detail = intent.getStringExtra("description_details");
          String movie_name = intent.getStringExtra("moviename_details");
          String movie_category = intent.getStringExtra("movie_category");
          String movie_durationz = intent.getStringExtra("movie_duration");
          String movie_time = intent.getStringExtra("movie_year");
          int image = intent.getIntExtra("image",0);
          String vidAddress = intent.getStringExtra("movie_links");
          imageCover.setImageResource(image);
          Uri vidUri = Uri.parse(vidAddress);
          vidView.setVideoURI(vidUri);
          mPlayButton = (ImageButton) findViewById(R.id.play_button);
          mPlayButton.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  vidView.start();
                  // hide button once playback starts
                      mPlayButton.setVisibility(View.GONE);
                  }
          });
  
          MediaController vidControl = new FullScreenMediaController(this);
          vidControl.setAnchorView(vidView);
          vidView.setMediaController(vidControl);
          description.setText(desc_detail);
          movienamedetails.setText(movie_name);
          movieCategory.setText(movie_category);
          movieDuration.setText(movie_durationz);
          movieYear.setText(movie_time);
      }
  }
  </code></pre>
  
  <p><strong>FullScreenMediaController :</strong></p>
  
  <pre><code>import android.app.Activity;
  import android.content.Context;
  import android.content.Intent;
  import android.view.Gravity;
  import android.view.View;
  import android.widget.FrameLayout;
  import android.widget.ImageButton;
  import android.widget.MediaController;
  
  public class FullScreenMediaController extends MediaController {
  
      private ImageButton fullScreen;
      private String isFullScreen;
  
      public FullScreenMediaController(Context context) {
          super(context);
      }
  
      @Override
      public void setAnchorView(View view) {
  
          super.setAnchorView(view);
  
          //image button for full screen to be added to media controller
          fullScreen = new ImageButton(super.getContext());
  
          FrameLayout.LayoutParams params =
                  new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                          LayoutParams.WRAP_CONTENT);
          params.gravity = Gravity.RIGHT;
          params.rightMargin = 80;
          addView(fullScreen, params);
  
          //fullscreen indicator from intent
          isFullScreen =  ((Activity)getContext()).getIntent().
                  getStringExtra("fullScreenInd");
  
          if("y".equals(isFullScreen)){
              fullScreen.setImageResource(R.drawable.fullscreenexit);
          }else{
              fullScreen.setImageResource(R.drawable.fullscreen);
          }
  
          //add listener to image button to handle full screen and exit full screen events
          fullScreen.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) {
  
                  Intent intent = new Intent(getContext(),DetailsActivity.class);
  
                  if("y".equals(isFullScreen)){
                      intent.putExtra("fullScreenInd", "");
                  }else{
                      intent.putExtra("fullScreenInd", "y");
                  }
                  ((Activity)getContext()).startActivity(intent);
              }
          });
      }
  }
  </code></pre>
  
  <p><strong>The log of error cause is :</strong> </p>
  
  <blockquote>
    <p>01-14 09:38:51.908 10500-10500/com.app.show E/AndroidRuntime: FATAL
    EXCEPTION: main Process: com.zeeshan.echoshow, PID: 10500
    java.lang.RuntimeException: Unable to start activity
    ComponentInfo{com.app.show/com.app.show.DetailsActivity}:
    java.lang.NullPointerException: uriString at
    android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3003)
    at
    android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3064)
    at android.app.ActivityThread.-wrap14(ActivityThread.java) at
    android.app.ActivityThread$H.handleMessage(ActivityThread.java:1659)
    at android.os.Handler.dispatchMessage(Handler.java:102) at
    android.os.Looper.loop(Looper.java:154) at
    android.app.ActivityThread.main(ActivityThread.java:6823) at
    java.lang.reflect.Method.invoke(Native Method) at
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1563)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1451)
    Caused by: java.lang.NullPointerException: uriString at
    android.net.Uri$StringUri.(Uri.java:475) at
    android.net.Uri$StringUri.(Uri.java) at
    android.net.Uri.parse(Uri.java:437) at
    com.zeeshan.echoshow.DetailsActivity.onCreate(DetailsActivity.java:63)
    at android.app.Activity.performCreate(Activity.java:6977) at
    android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
    at
    android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946)
    at
    android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3064)
    at android.app.ActivityThread.-wrap14(ActivityThread.java)  at
    android.app.ActivityThread$H.handleMessage(ActivityThread.java:1659) 
    at android.os.Handler.dispatchMessage(Handler.java:102)  at
    android.os.Looper.loop(Looper.java:154)  at
    android.app.ActivityThread.main(ActivityThread.java:6823)  at
    java.lang.reflect.Method.invoke(Native Method)</p>
  </blockquote>
  
  <p><strong>App Screenshot:</strong> </p>
  
  <p><a href="https://i.stack.imgur.com/Ju16U.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ju16U.jpg" alt="enter image description here"></a></p>