使用新的系统 WebView?
Using new System WebView?
如何在这种网页视图中打开链接
而不是 phone 安装浏览器?
编辑
使用此代码无效:
public class WebsiteActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView webView = new WebView(this);
setContentView(webView);
webView.loadUrl("http://www.google.com");
编辑 2
使用上面的代码会导致:
但我想要这个:
将此添加到您的 build.gradle 文件中
dependencies {
...
compile 'com.android.support:customtabs:23.3.0'
}
打开 Chrome 自定义选项卡
// Use a CustomTabsIntent.Builder to configure CustomTabsIntent.
// Once ready, call CustomTabsIntent.Builder.build() to create a CustomTabsIntent
// and launch the desired Url with CustomTabsIntent.launchUrl()
String url = ¨https://paul.kinlan.me/¨;
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build() ;
customTabsIntent.launchUrl(this, Uri.parse(url));
如何在这种网页视图中打开链接
而不是 phone 安装浏览器?
编辑
使用此代码无效:
public class WebsiteActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView webView = new WebView(this);
setContentView(webView);
webView.loadUrl("http://www.google.com");
编辑 2
使用上面的代码会导致:
但我想要这个:
将此添加到您的 build.gradle 文件中
dependencies {
...
compile 'com.android.support:customtabs:23.3.0'
}
打开 Chrome 自定义选项卡
// Use a CustomTabsIntent.Builder to configure CustomTabsIntent.
// Once ready, call CustomTabsIntent.Builder.build() to create a CustomTabsIntent
// and launch the desired Url with CustomTabsIntent.launchUrl()
String url = ¨https://paul.kinlan.me/¨;
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build() ;
customTabsIntent.launchUrl(this, Uri.parse(url));