簡體   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