Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Runtime Exception in doInBackground
    primarykey
    data
    text
    <p>I'm not able to find whats wrong with this code. Someone please help me out. I used same code in other project as well and in that project it worked fine. I'm just trying to open a URL to load it in a <code>WebView</code> and I already gave internet permission in the <code>manifest</code> file. Here's the code:</p> <pre><code>package com.example.itmuantiragging; import android.annotation.SuppressLint; import android.app.Fragment; import android.app.ProgressDialog; import android.graphics.Bitmap; import android.os.AsyncTask; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.Toast; @SuppressLint("NewApi") public class Fragment_Website extends Fragment { WebView wv; ProgressDialog pg; Background bg; public Fragment_Website() {} @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_website, container,false); //Toast.makeText(getActivity(), "Loading... Please Wait..",Toast.LENGTH_LONG).show(); wv = (WebView) rootView.findViewById(R.id.webView1); bg = new Background(); bg.execute(); return rootView; } public void progress(){ pg = new ProgressDialog(getActivity()); pg.setTitle(""); pg.setMessage("Please Wait........."); pg.setCancelable(false); pg.setIndeterminate(true); pg.show(); } class Background extends AsyncTask&lt;Void, Void, Void&gt; { @SuppressLint("SetJavaScriptEnabled") @Override protected Void doInBackground(Void... arg0) { // TODO Auto-generated method stub try{ wv.loadUrl("http://www.siddharth.uphero.com/MTNL_address_locator.html"); }catch(Exception e){ e.printStackTrace(); } wv.getSettings().setJavaScriptEnabled(true); wv.getSettings().setLoadWithOverviewMode(true); wv.getSettings().setUseWideViewPort(true); wv.getSettings().setBuiltInZoomControls(true); wv.setWebViewClient(new MyWebClient()); return null; } @Override protected void onPostExecute(Void result) { } @Override protected void onPreExecute() { progress(); } } public class MyWebClient extends WebViewClient { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { // TODO Auto-generated method stub super.onPageStarted(view, url, favicon); } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { // TODO Auto-generated method stub view.loadUrl(url); return true; } @Override public void onPageFinished(WebView view, String url) { // TODO Auto-generated method stub super.onPageFinished(view, url); pg.dismiss(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload