Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display Web site in Android WebView

I am new to Android WebView, in my application i need to display a web site conatins 3 web pages. In the first web page there will be a link to navigate to the second page and second to third page. I given the URL in the WebView, the first page is displayed perfectly, when i click the link it directly opens the browser application to display the second page. But i want to display the second page in the WebView itself. Please find my code below:

  WebView forumView=(WebView)findViewById(R.id.forumView);
  forumView.getSettings().setJavaScriptEnabled(true);  
  forumView.loadUrl("url");

As i said i am very new to WebView my code might be wrong, please help me to solve this problem.

Thanks in Advance, Rajapandian

like image 835
Rajapandian Avatar asked Oct 28 '25 08:10

Rajapandian


1 Answers

This piece of code will help you.

wbb = (WebView) findViewById(R.id.webView_tobe_loaded);

    WebSettings wbset=wbb.getSettings();
    wbset.setJavaScriptEnabled(true);
    wbb.setWebViewClient(new MyWebViewClient());
    String url="http://www.google.com";

    System.out.println(getdeviceid());
    wbb.getSettings().setJavaScriptEnabled(true);
    wbb.loadUrl(url);
like image 197
Sreedev Avatar answered Oct 29 '25 21:10

Sreedev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!