使用新的System WebView?

时间:2016-09-15 00:13:59

标签: android android-webview

如何在此类网页浏览中打开链接

System Webview

而不是手机安装浏览器?

Chrome browser

修改

使用此代码无效:

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

使用上面的代码将导致:

Inside app

但我想要这个:

System webview

1 个答案:

答案 0 :(得分:1)

在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));