android首屏广告页跳转,Android两种实现跳转网页的方式

  • Post author:
  • Post category:其他


(1) 方式一

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

//方式一:代码实现跳转

Intent intent = new Intent();

intent.setAction(“android.intent.action.VIEW”);

Uri content_url = Uri.parse(“https://www.baidu.com/”);//此处填链接

intent.setData(content_url);

startActivity(intent);

}

(1) 方式二

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

//方式二:Webview控件跳转网页

WebView wv = findViewById(R.id.wv);

wv.loadUrl(“http://www.hao123.com”);

}

xmlns:app=”http://schemas.android.com/apk/res-auto”

xmlns:tools=”http://schemas.android.com/tools”

android:layout_width=”match_parent”

android:orientation=”vertical”

android:layout_height=”match_parent”>

android:id=”@+id/wv”

android:layout_width=”match_parent”

android:layout_height=”wrap_content”>