首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >对于华为来说,有像ChromeCustomTabs或SafariViewController那样的替代方案吗?

对于华为来说,有像ChromeCustomTabs或SafariViewController那样的替代方案吗?
EN

Stack Overflow用户
提问于 2021-05-06 10:26:47
回答 1查看 611关注 0票数 5

ChromeCustomTabs使用Chrome,SafariViewController使用Safari。华为(华为浏览器)是否有其他选择?我可以使用华为浏览器作为应用程序内浏览器吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-07 03:22:21

我可以用华为浏览器作为应用程序内的浏览器吗?

是的,你可以,华为浏览器支持CustomTabs。

可以使用下列任何一种方法启动自定义选项卡:

1.使用支持包提供的公共接口。详情如下:

Maven依赖于支持包。

代码语言:javascript
复制
 dependencies {
    ...
    compile 'com.android.support:customtabs:23.3.0'
}

然后使用支持包的CustomTabIntent.Builder启动构建。

代码语言:javascript
复制
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.启动华为浏览器自定义选项卡。

代码语言:javascript
复制
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);
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67416270

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档