Android WebView not loading URL

前端 未结 10 911
鱼传尺愫
鱼传尺愫 2020-12-05 02:15

I want to load the URL in WebView

I have used the following Code:

webView = (WebView) findViewById(R.id.webview1);
webView.setWebViewCli         


        
10条回答
  •  温柔的废话
    2020-12-05 02:18

    Add Permission Internet permission in manifest.

    as

    This code it working

      public class WebActivity extends Activity {
      WebView wv;
    
     String url="http://www.teluguoneradio.com/rssHostDescr.php?hostId=147";
    
     @Override
     protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_web);
        wv=(WebView)findViewById(R.id.webUrl_WEB);
    
    
    
    WebSettings webSettings = wv.getSettings();
        wv.getSettings().setLoadWithOverviewMode(true);
        wv.getSettings().setUseWideViewPort(true);
        wv.getSettings().setBuiltInZoomControls(true);
        wv.getSettings().setPluginState(PluginState.ON);
    
    
        wv.setWebViewClient(new myWebClient());
    
        wv.loadUrl(url);
    }
    
    
    
    
    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;
    
        }
    }
    

提交回复
热议问题