title: How to dismiss a dialog containing a WebView from the WebView class
body: <p>I am trying to make webview as a dialog in my android app, and close it when I load needed webpage. dialog opens on button click in activity, and if close dialog just after opening(in activity), it's work, but in my WebViewClient it always crash. dialog create:</p>
  
  <pre><code>@Override
      protected Dialog onCreateDialog(int id) {
           switch (id) {
           case 1:
               dialog = new Dialog(this);
               dialog.setContentView(R.layout.webviewl);
               dialog.setCanceledOnTouchOutside(false);
               webview = (WebView) dialog.findViewById(R.id.vkWebView);
               webview.setWebViewClient(wvClforVK);
               webview.loadUrl(url);
           webview.requestFocus(View.FOCUS_DOWN);
           return dialog;
           default:
           return super.onCreateDialog(id);
              }
      }   
      public void showVKDialog(){
           dialog = new Dialog(this);
           dialog.setContentView(R.layout.webviewl);
           dialog.setCanceledOnTouchOutside(false);
           webview = (WebView) dialog.findViewById(R.id.vkWebView);
           webview.setWebViewClient(wvClforVK);
           webview.loadUrl(url);
           dialog.show();
      }
  public void dismissDialog(){
          dialog.dismiss();
      }
  </code></pre>
  
  <p>open on button</p>
  
  <pre><code>showDialog(1);
  </code></pre>
  
  <p>in WebViewClass:</p>
  
  <pre><code>//code
      @Override
              public void onPageFinished (WebView webview, String url){
          //lalala some kind of my perfect code.... :)
  
   Activity myActivity = new Activity();
               myActivity.dismissDialog();
  </code></pre>
  
  <p>web view layout:</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="wrap_content"
      android:layout_height="wrap_content"
      android:orientation="vertical" &gt;
  
      &lt;WebView
          android:id="@+id/vkWebView" 
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>