华为有没有像ChromeCustomTabs或SafariViewController一样工作的替代品?
ChromeCustomTabs uses Chrome, SafariViewController uses Safari. Is there an alternative for Huawei (Huawei Browser). Can I use Huawei Browser as an in-app browser?
回答
我可以将华为浏览器用作应用内浏览器吗?
可以,华为浏览器支持自定义标签。
您可以使用以下任一方法启动自定义选项卡:
1.使用支持包提供的公共接口。详细情况如下:
Maven 依赖于支持包。
dependencies {
...
compile 'com.android.support:customtabs:23.3.0'
}
然后使用支持包的 CustomTabIntent.Builder 开始构建。
String url = ¨https://paul.kinlan.me/¨;
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.intent.setPackageName(“com.huawei.browser”);
customTabsIntent.launchUrl(this, Uri.parse(url));
customTabsIntent.intent.setPackageName(“com.huawei.browser”);表示启动华为浏览器的自定义标签页。您还可以更改其他浏览器的包名称以启动其他浏览器的自定义选项卡。
2.通过启动intent来启动华为浏览器自定义标签。
String url = ¨https://paul.kinlan.me/¨;
Intent customTabsIntent = new Intent(Intent.ACTION_VIEW);
customTabsIntent.setData(Uri.parse(url))) ;
Bundle bundle = new Bundle();
bundle.putBinder(EXTRA_SESSION, null);
customTabsIntent.putExtras(bundle);
customTabsIntent.intent.setPackageName(“com.huawei.browser”);
startActivity(customTabsIntent);
THE END
二维码