1

I have web view in which I am loading the URL.

Its working fine when I load http://www.google.co.in/

But, its not showing anything when I am loading http://edition.cnn.com/ its opening the browser with this url.

Why this is happening and how to avoid it.

Thanks in advance...!

1 Answer 1

1

edition.cnn.com redirect you to mobile site version

http://developer.android.com/resources/tutorials/views/hello-webview.html

You now have a simplest web page viewer. It's not quite a browser yet because as soon as you click a link, the default Android Browser handles the Intent to view a web page, because this Activity isn't technically enabled to do so. Instead of adding an intent filter to view web pages, you can override the WebViewClient class and enable this Activity to handle its own URL requests.

sample:

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.test); WebView w = (WebView) findViewById(R.id.webView); w.getSettings().setJavaScriptEnabled(true); w.setWebViewClient(new HelloWebViewClient()); w.loadUrl("http://edition.cnn.com/"); } private class HelloWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.