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