title: playing video on android webview does not fullscreen
body: <p>I am making a webview application which shows pages they have html5 videos in it. when I tap the fullscreen, video dissapears.</p>
  
  <p>when I searching same problems, saw <a href="https://stackoverflow.com/q/15768837/1265083">this</a> question, which is same problem with me, and thought 2nd answer (<a href="https://stackoverflow.com/a/16179544/1265083">here</a>) fits for me also.
  Even I use classes given in the answer, I am still having these errors and application stoped.</p>
  
  <pre><code>05-03 13:41:50.064: E/AndroidRuntime(19292): FATAL EXCEPTION: main
  05-03 13:41:50.064: E/AndroidRuntime(19292): java.lang.NullPointerException
  05-03 13:41:50.064: E/AndroidRuntime(19292):    at com.zapkolik.mayis.VideoEnabledWebChromeClient.onShowCustomView(VideoEnabledWebChromeClient.java:132)
  05-03 13:41:50.064: E/AndroidRuntime(19292):    at android.webkit.HTML5VideoFullscreen.enterFullscreen(HTML5VideoFullscreen.java:239)
  05-03 13:41:50.064: E/AndroidRuntime(19292):    at android.webkit.HTML5VideoView.enterFullscreenVideoState(HTML5VideoView.java:544)
  05-03 13:41:50.064: E/AndroidRuntime(19292):    at android.webkit.HTML5VideoViewProxy$VideoPlayer.enterFullscreenVideo(HTML5VideoViewProxy.java:182)
  05-03 13:41:50.064: E/AndroidRuntime(19292):    at android.webkit.HTML5VideoViewProxy.handleMessage(HTML5VideoViewProxy.java:479)
  05-03 13:41:50.064: E/AndroidRuntime(19292):    at android.os.Handler.dispatchMessage(Handler.java:99)
  .
  .
  .
  </code></pre>
  
  <p>my activity is here:</p>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>package com.zapkolik.mayis;
  
  import android.os.Bundle;
  import android.app.Activity;
  import android.app.AlertDialog;
  import android.text.method.HideReturnsTransformationMethod;
  import android.view.Menu;
  import android.view.View;
  import android.view.ViewGroup;
  import android.webkit.WebView;
  import android.webkit.WebViewClient;
  import android.widget.Toast;
  
  public class MainActivity extends Activity {
  
  private VideoEnabledWebView webView;
  private VideoEnabledWebChromeClient webChromeClient;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      // Save the web view
      webView = (VideoEnabledWebView) findViewById(R.id.webView);
  
      // Initialize the VideoEnabledWebChromeClient and set event handlers
      View nonVideoLayout = findViewById(R.id.nonVideoLayout); // Your own view, read class comments
      ViewGroup videoLayout = (ViewGroup) findViewById(R.layout.video_layout); // Your own view, read class comments
      View loadingView = getLayoutInflater().inflate(R.layout.loading_video, null);
  // Your own view, read class comments
  
      final Activity activity = this;
      webChromeClient = new VideoEnabledWebChromeClient(nonVideoLayout, videoLayout, loadingView, webView) // See all available constructors...
      {
          // Subscribe to standard events, such as onProgressChanged()...
  
          @Override
          public void onProgressChanged(WebView view, int progress)
          {
              activity.setProgress(progress * 1000);
          }
      };
      webChromeClient.setOnToggledFullscreen(new VideoEnabledWebChromeClient.ToggledFullscreenCallback()
      {
          @Override
          public void toggledFullscreen(boolean fullscreen)
          {
  //              AlertDialog alertDialog = new AlertDialog.Builder(activity).create(); //Read Update
  //              alertDialog.setTitle("hi");
  //              alertDialog.setMessage("this is my app");
          }
      });
      webView.setWebChromeClient(webChromeClient);
      webView.setWebViewClient(new WebViewClient());
  
      // Navigate everywhere you want, this classes have only been tested on YouTube's mobile site
      webView.loadUrl("http://m.youtube.com");
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  
  @Override
  public void onBackPressed()
  {
      // Notify the VideoEnabledWebChromeClient, and handle it ourselves if it doesn't handle it
      if (!webChromeClient.onBackPressed())
      {
          if (webView.canGoBack())
          {
              webView.goBack();
          }
          else
          {
              // Close app (presumably)
              super.onBackPressed();
          }
      }
  }
  
  }
  </code></pre>
  
  <p>and layouts are:</p>
  
  <p><strong>activity_main.xml</strong></p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/nonVideoLayout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".MainActivity" &gt;
  
      &lt;com.zapkolik.mayis.VideoEnabledWebView
          android:id="@+id/webView"
          android:layout_width="match_parent"
          android:layout_height="match_parent" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>loading_video.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_margin="@dimen/center"
      android:gravity="center|center_vertical"
      android:orientation="vertical" &gt;
  
      &lt;ProgressBar
          android:id="@+id/progressBar1"
          style="?android:attr/progressBarStyleLarge"
          android:layout_width="208dp"
          android:layout_height="0dip"
          android:layout_weight="0.39" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>video_layout.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;VideoView xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/videoView1"
      android:layout_width="match_parent"
      android:layout_height="wrap_content" /&gt;
  </code></pre>
  
  <p>I could not figure out why I am getting errors when I tap the fullscreen button. </p>