WebView invoking the browser

Source: Internet
Author: User

It's the same as the intent function. I don't know ...

First go to androidmainfest Modify permissions, add Network access rights

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

Add WebView to Layout

<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical" >    <WebViewAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:id= "@+id/webview"        /></LinearLayout>

Then go to the master file to modify

 PackageCom.example.deemo;Importandroid.app.Activity;Importandroid.content.Intent;ImportAndroid.net.Uri;ImportAndroid.os.Bundle;ImportAndroid.view.View;ImportAndroid.view.View.OnClickListener;ImportAndroid.webkit.WebView;ImportAndroid.widget.Button; Public classMainactivityextendsactivity{PrivateString url= "http://www.bilibili.com";//Address    PrivateWebView WebView; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.layout.activity_main); //uri uri = uri.parse (URL);//Link Address//Intent Intent = new Intent (Intent.action_view,uri);//the above document and the following objectives//startactivity (intent);//to jumpInit ();//Execution Method        }        //Construction Method    Private voidinit () {//TODO auto-generated Method Stubwebview=(WebView) Findviewbyid (R.id.webview); //Local Resource Webview.loadurl (file:///android_asset/file name)Webview.loadurl (URL);//Open External    }}

WebView invoking the browser

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.