To open a Web page in an application using WebView

Source: Internet
Author: User

If you want to display some Web pages in your application and embed a browser in your application, you can use the WebView control to call the Loadurl () method to load the display

The corresponding Web page.

WebView = (WebView) Findviewbyid (R.id.web_view); Webview.loadurl ("http://www.baidu.com");

You may also jump directly to the system browser and need to override the Shouldoverrideurlloading () method to implement jumps in the WebView.

        Webview.setwebviewclient (new  webviewclient () {            @Override            publicBoolean  shouldoverrideurlloading (WebView view, String URL) {                //  TODO auto-generated method Stub                View.loadurl (URL); Load a new page based on the parameters passed in
                 returntrue;  //indicates that the current WebView can handle requests to open a new webpage without using the System browser
} }); Webview.loadurl (URL);

We also need to add permissions to the Androidmanifest.xml, otherwise the URL will be inaccessible

< Manifest > ... <  android:name= "Android.permission.INTERNET"/> ... </ Manifest >

To open a Web page in an application using WebView

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.