title: How to finish activity in javainterface class webview android?
body: <p>I have webview . I want HTML data so i used</p>
  
  <pre><code>webView = (WebView) findViewById(R.id.webview);
  webView.getSettings().setJavaScriptEnabled(true);
  webView.addJavascriptInterface(new WebInterface(this), "HtmlViewer");
  </code></pre>
  
  <p>and Interface class</p>
  
  <pre><code>class WebInterface {
  
          private Context ctx;
  
          WebInterface(Context ctx) {
              this.ctx = ctx;
          }
  
          @JavascriptInterface
          public void showHTML(String html) {
              DialogManager.showCustomDialog("title", 
                      "msg", ctx, new DialogStateListener() {
                  @Override
                  public void onClick(int state) {
                      finish();
                  }
              });
          }
      }
  </code></pre>
  
  <p>I am calling finish but activity not destroyed.</p>
  
  <p>I Also tried </p>
  
  <pre><code>onBackPressed();
  </code></pre>
  
  <p>and </p>
  
  <pre><code>((Activity) ctx).finish();
  MyActivity.this.finish();
  </code></pre>
  
  <p>I just want to finish activity inside dialog.</p>