Android - setting WebViewClient causes NullPointerException in AsyncTask
<p>So I have this AsyncTask that loads a WebView in onPostExecute that otherwise works perfectly, however I need to do something for onLoadResource so I'm trying to set a WebViewClient and for some reason that is causing a NullPointerException</p>

<pre>
private class newThread extends AsyncTask{
     private WebView webview;

...

protected void onPostExecute(Void result){
    setContentView(R.layout.reply);
    webview.setWebViewClient(new WebViewClient(){
        @Override
        public boolean shouldOverrideUrlLoading(WebView  view, String  url){
            return true;
        }
        @Override
        public void onLoadResource(WebView  view, String  url){
            finish();
        }
    });
    webview = (WebView)findViewById(R.id.replyview);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.setScrollBarStyle(0);
    webview.loadDataWithBaseURL("http://example.com", "example", "text/html", "utf-8", null);
}

...


</pre>

<p>Is there something wrong in that code?  </p>

<p>If I use basically the same method but outside of an AsyncTask then there's no errors. And if I remove the setWebViewClient lines then it runs fine.</p>
