Var*_*rma 4 android chrome-custom-tabs
我有一个chrome自定义选项卡,但我想在标题栏左上角的关闭(X)按钮中添加一个监听器.
我想在每次用户点击关闭按钮时触发回调.
我能够在Web视图中执行此操作,但无法确定是否可以使用chrome自定义选项卡.
这是我用来调用自定义标签的代码段:
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.enableUrlBarHiding();
builder.setToolbarColor(getTitleBarBackgroundColor());
builder.setStartAnimations(this, android.R.anim.slide_in_left, android.R.anim.slide_out_right);
builder.setExitAnimations(this, android.R.anim.slide_in_left, android.R.anim.slide_out_right);
customTabsIntent = builder.build();
customTabsIntent.intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
customTabsIntent.launchUrl(this, Uri.parse(url));
Run Code Online (Sandbox Code Playgroud)
已经有一些关于Chrome自定义选项卡关闭按钮定制的quires(此处和此处)用于不同目的.从Chrome自定义选项卡的当前实现,无法将侦听器直接添加到chrome自定义选项卡关闭按钮.您只能自定义其图标的关闭按钮.
更新:虽然您无法直接向Chrome自定义标签关闭按钮添加监听器,但您可以通过使用打开chrome自定义选项卡的来电活动的onResume()或onActivityResult()来解除对Chrome自定义标签的解除.但请记住,在这种情况下,无论Chrome自定义选项卡是通过关闭按钮还是设备返回键关闭,都将调用回调.
| 归档时间: |
|
| 查看次数: |
4909 次 |
| 最近记录: |