标签: android-customtabs

自定义标签支持库

最近添加了这个支持库,但我找不到任何例子.

这个图书馆的目的是什么?

你能用这个库发布任何例子吗?

android android-support-library android-customtabs

31
推荐指数
1
解决办法
2万
查看次数

Android浏览器会从完整限定符中删除https://方案

在我的应用程序中,我在CustomTabsIntent或WebView中显示外部HTML站点:

if (customTabsIntent != null) customTabsIntent.launchUrl(this, Uri.parse("http://some.where.com/site.html"));
else startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://some.where.com/site.html")));
Run Code Online (Sandbox Code Playgroud)

但该HTML的风格已经更新,但我的智能手机显示旧样式(旧字体等).

在*.html文件中有一个*.css引用:

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <link href='https://my.site.com/assets/css/style.css' rel='stylesheet' type='text/css'>
</head>
Run Code Online (Sandbox Code Playgroud)

在那个*.css文件中,引用了一个单独的字体; 例如:

@font-face {
    font-family: 'MyFontRegular';
    src: url('https://www.openfont.org/assets/mail/fonts/MyFontWeb-Regular.woff') format('woff'), 
    url('https://www.openfont.org/assets/mail/fonts/MyFontWeb-Regular.eot') format('embedded-opentype');
}
Run Code Online (Sandbox Code Playgroud)

正如我所说,智能手机中的Chrome浏览器不显示引用的字体,因为它会关闭http://https://.当我手动将该方案添加到地址栏中时,将显示正确的样式.

当我的Android应用程序调用它时,如何在我的android浏览器的地址字段中强制https://方案?

android webview android-webview chrome-custom-tabs android-customtabs

15
推荐指数
1
解决办法
346
查看次数

如何使用Chrome自定义标签(Fitbit API)登录OAuth 2.0

Fitbit API不再支持webview.

所以,我研究了chrome自定义标签并在我的应用中应用.

但登录后,当我按下这个粉红色按钮(允许按钮)时,没有任何反应.(图片如下)

Fitbit API登录图片

如何接收访问令牌并将其存储在应用程序中?

请帮我.

谢谢.

android oauth-2.0 fitbit chrome-custom-tabs android-customtabs

11
推荐指数
1
解决办法
4979
查看次数

Chrome 自定义选项卡中的重定向未捕获深层链接

我想捕获 Chrome 自定义选项卡中发生的重定向,以确保用户留在本机移动应用程序中。

Chrome 自定义选项卡的启动方式如下:

val url = "https://demo.company.com/sso/oidc/start/?idp_connection_id=Username-Password-Authentication&status_response_url=https://member.example.com/urgent"
val builder = CustomTabsIntent.Builder()                                                                                                                                         
val customTabsIntent = builder.build()                                                                                                                                           
customTabsIntent.launchUrl(this, Uri.parse(url))
Run Code Online (Sandbox Code Playgroud)

status_response_url在用户进行身份验证后,该网页将重定向到作为参数给出的 URL 。移动应用程序注册适当的方案:

 <intent-filter android:autoVerify="true">
     <action android:name="android.intent.action.VIEW" />
     <category android:name="android.intent.category.DEFAULT" />
     <category android:name="android.intent.category.BROWSABLE" />
     <data
         android:host="member.example.com"
         android:scheme="https" />
  </intent-filter>
Run Code Online (Sandbox Code Playgroud)

不幸的是,系统似乎没有捕获重定向。为什么?

android intentfilter chrome-custom-tabs android-customtabs android-deep-link

11
推荐指数
1
解决办法
6333
查看次数

通过 CustomTab 或 Chrome POST 数据

我想通过 CustomTab 或 Chrome 发送 POST HTTP 请求,然后最终显示页面。我进行了很多研究,但没有办法。有办法吗?可以通过 Volley 发送 POST 请求然后最终在浏览器中显示响应吗?

java android android-volley chrome-custom-tabs android-customtabs

8
推荐指数
1
解决办法
2333
查看次数

带有深层链接的 Android 自定义 chrome 选项卡

我有一个 Android/Kotlin 应用程序,我想为某些页面配置深层链接以在我的应用程序中打开(以看起来原生)。

目前,我有意图过滤器,可以将用户重定向到带有 WebView 的活动,在其中打开所需的 url:

<activity android:name=".activity.WebViewActivity">
        <intent-filter android:label="Futurity">
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="api.example.com"
                android:pathPrefix="/auth/confirm"
                android:scheme="https" />
        </intent-filter>
</activity>

class WebViewActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_web_view)

        val data = intent.data

        // construct url
        val url = if (intent.data != null ) {
            "https://" + data.host + data.path + "?" + data.query
        }

        appWebView.webViewClient = WebViewClient()
        appWebView.loadUrl(url)
    }
}
Run Code Online (Sandbox Code Playgroud)

这工作正常,但出于安全原因我想使用 Chrome 自定义选项卡。

但是,当我尝试配置自定义选项卡而不是 WebView 时,我在页面(在 chrome 选项卡中启动)和意图过滤器之间出现无限循环的重定向,该过滤器立即将用户重定向回活动:

CustomTabsIntent.Builder …
Run Code Online (Sandbox Code Playgroud)

android kotlin android-customtabs

7
推荐指数
1
解决办法
3492
查看次数

有哪些浏览器不支持自定义选项卡功能?

我尝试过 Opera 浏览器,opera mini,UC mini,duckduckgo 都支持自定义选项卡,只是想知道到了 2022 年还有浏览器仍然不支持自定义选项卡吗?

android google-chrome chrome-custom-tabs android-customtabs

7
推荐指数
1
解决办法
1779
查看次数

是否可以使 Chrome CustomTabs 意图不打开外部应用程序?

我希望 Chrome CustomTab 始终打开 Chrome CustomTab 中的网址。即使有意图可以转到的外部应用程序。现在,系统会提示用户是否要在 Chrome 或外部应用程序中打开。是否可以强制意图通过 Chrome?我知道 WebView 可以工作,但 CustomTab 有更多功能......

android google-chrome android-intent android-customtabs

5
推荐指数
1
解决办法
4858
查看次数

如何在未登录的情况下将任何 URL 启动到 Chrome 自定义选项卡

我有一个 android 示例应用程序,我想在Chrome Custom Tab而不是WebView中打开任何 URL 。我正在尝试从https://developer.chrome.com/multidevice/android/customtabs并能够做到这一点。

在这里我面临一个问题,那就是 -

如果我已经从Chrome 浏览器登录 facebook ,那么当我将 facebook url 启动到Chrome 自定义选项卡时,它也会显示为已登录。

Chrome 自定义选项卡似乎正在使用Chrome 浏览器的 cookie 。但我想将任何 URL以“未登录”状态启动到Chrome 自定义选项卡中,无论Chrome 浏览器的登录状态如何。

问题是我没有找到任何方法来清除chrome自定义选项卡的cookie,尽管之前我通过webview的“cookieManager.removeAllCookie()”清除了cookie。

是否可以在启动 URL 之前清除 chrome 自定义选项卡的 cookie,任何人都可以帮助实现这一目标吗?

这是我的代码,用于将 URL 启动到 chrome 自定义选项卡中 -

private void launchURL(String url) {
    CustomTabsIntent.Builder builderCustomTabs = new CustomTabsIntent.Builder();
    CustomTabsIntent intentCustomTabs = builderCustomTabs.build();
    intentCustomTabs.intent.setPackage("com.android.chrome");
    intentCustomTabs.intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intentCustomTabs.launchUrl(this, Uri.parse(url));
}
Run Code Online (Sandbox Code Playgroud)

android chrome-custom-tabs android-customtabs

5
推荐指数
1
解决办法
4502
查看次数

如何打开 WebView 或从自定义选项卡中分离 Chrome 活动

我目前正在按照Google 示例 TWA 项目中的指南构建一个 Android 应用程序作为 TWA,并且在尝试从 TWA 中打开外部链接时遇到了一个问题。

在我的 TWA 中,当打开外部链接(例如 Facebook 或 Instagram)并且我没有安装可以处理该链接的应用程序时,我希望该链接在我的应用程序之外在 Chrome 中单独打开。然而,TWA 实现是围绕并在 Google 的自定义选项卡中构建的,它似乎坚持在自定义选项卡上下文中加载链接。

像这样从我的应用程序中打开外部链接的问题是,当单击“关闭”图标时,它会关闭我的整个应用程序,而不仅仅是外部链接的视图,这显然是不可取的。

TL;DR 有没有一种方法可以强制从自定义选项卡上下文外部打开自定义选项卡内的外部链接?作为单独的 Chrome 活动或作为 Web 视图就足够了。

请注意,我的应用确实有一个意图过滤器和范围集:

           <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data
                    android:host="www.example.com"
                    android:pathPrefix="/mobile"
                    android:scheme="https" />
            </intent-filter>
Run Code Online (Sandbox Code Playgroud)

android android-webview android-activity android-customtabs trusted-web-activity

5
推荐指数
1
解决办法
471
查看次数