繁体   English   中英

是否可以在 Chrome 自定义选项卡上隐藏 URL 栏

[英]Is it possible to hide URL bar on Chrome Custom Tabs

正如标题所说,我正在寻找一种方法来隐藏网址栏。

到目前为止,我已经得到了这个,但它没有改变任何东西。

CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
        builder.setShowTitle(false);
        builder.enableUrlBarHiding();
        CustomTabsIntent customTabsIntent = builder.build();
        customTabsIntent.launchUrl(this, Uri.parse(url));

我尝试使用 webviews,但在文件上传和某些无法正常工作的 css 方面,我遇到了无穷无尽的问题。 自定义选项卡在所有这些方面都运行良好,而且看起来更快。

根据@113408 的回答,我正在尝试实施 TWA,我已经让它工作,将网站和应用程序之间的链接以及应用程序添加到网站,但 URL 栏仍然可行。

这是清单文件,因为它是我完成的唯一编码。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.app.comppanynme.twatest">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme" >

        <meta-data
            android:name="asset_statements"
            android:resource="@string/asset_statements" />

        <activity
            android:name="android.support.customtabs.trusted.LauncherActivity">

            <!-- Edit android:value to change the url opened by the TWA -->
            <meta-data
                android:name="android.support.customtabs.trusted.DEFAULT_URL"
                android:value="http://192.168.8.46" />

            <!-- This intent-filter adds the TWA to the Android Launcher -->
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <!--
              This intent-filter allows the TWA to handle Intents to open
              airhorner.com.
            -->
            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE"/>

                <!-- Edit android:host to handle links to the target URL-->
                <data
                    android:scheme="http"
                    android:host="192.168.8.46"/>
            </intent-filter>
        </activity>
    </application>
</manifest>

这是我的资产声明

<string name="asset_statements">
        [{
            \"relation\": [\"delegate_permission/common.handle_all_urls\"],
            \"target\": {
                \"namespace\": \"web\",
                \"site\": \"http://192.168.8.46"}
        }]
    </string>

您可以使用受信任的 Web 活动实现所需的结果

受信任的 Web 活动是一种使用基于自定义选项卡的协议将您的 Web 应用程序内容(例如 PWA)与您的 Android 应用程序集成的新方法。

最终,TWA 将允许您执行与CustomChromeTabs完全相同的操作,但提供更多功能。

您正在寻找更具体的是删除 URL 栏

受信任的 Web 活动需要在 Android 应用程序和要建立的网站之间建立关联以删除 URL 栏。

注意:隐藏 URL 栏时,请确保您通过HTTPS提供您的页面,否则您将无法隐藏,因为该页面被认为是不安全的。

如何在 5 分钟内让 HTTPS 在本地开发环境中运行

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM