「受信任的網路活動」總覽
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
受信任的網路活動是一種新方法,可透過以自訂分頁為基礎的通訊協定,從 您的 Android 應用程式開啟 您的 網路應用程式內容,例如漸進式網頁應用程式 (PWA)。
注意:Android 版 Chrome 72 以上版本支援受信任的網路活動。
尋找程式碼?
與透過 Android 應用程式開啟網頁內容的其他方式相比,受信任的網路活動有以下幾項不同之處:
- 受信任的網路活動中的內容是「受信任」的,也就是說,應用程式和該應用程式開啟的網站應來自同一位開發人員。(這項資訊會透過 Digital Asset Links 驗證)。
- 信任的網路活動中顯示的內容來自網路:這些內容是由使用者的瀏覽器顯示,與使用者在瀏覽器中看到的內容完全相同,只是會以全螢幕模式顯示。網頁內容必須先在瀏覽器中可供存取且實用。
- 瀏覽器也會獨立於 Android 和應用程式更新,這樣一來可縮減 APK 大小,並確保您能使用新式網頁執行階段。(請注意,自 Lollipop 起,WebView 也已獨立於 Android 更新,但 Lollipop 之前的 Android 使用者有大量人數。)
- 主機應用程式無法直接存取信任的網路活動中的網路內容,或任何其他類型的網路狀態,例如 Cookie 和
localStorage
。不過,您可以透過網址傳遞資料至網頁,並從網頁接收資料 (例如透過查詢參數和意圖 URI),藉此與網站內容進行協調。
- 網頁和原生內容之間的轉換是發生在活動之間。應用程式的每項活動 (即畫面) 都由網路或 Android 活動完全提供
為方便測試,目前在可信任的網頁活動預覽畫面中,開啟的內容不需符合任何資格條件。不過,可信任的網頁活動必須符合相同的新增至主畫面規定。您可以使用 Lighthouse 的「使用者可收到新增至主畫面的提示」稽核項目,稽核網站是否符合這些規定。
目前,其他瀏覽器可以導入與信任網頁活動相同的通訊協定。雖然主機應用程式可決定要開啟哪個瀏覽器,但我們建議您採用自訂分頁的相同政策:使用使用者的預設瀏覽器,前提是該瀏覽器提供必要功能。
接下來要去哪裡?
如果您想快速建構 Android 應用程式,並直接啟動及開啟 PWA,請參閱快速入門指南。
如果您想將 Trusted Web Activity 整合至現有的 Android 應用程式,請參閱整合指南,瞭解如何開始操作。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[null,null,["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Overview of Trusted Web Activities\n\n**Trusted Web Activity** is a new way to open *your* web-app content such as *your* Progressive Web App (PWA) from *your* Android app using a protocol based on Custom Tabs.\n\n**Note** : Trusted Web Activity is available in [Chrome on Android](https://play.google.com/store/apps/details?id=com.android.chrome), version 72 and above.\n\n*Looking for the code?*\n\n- [android-browser-helper library on GitHub](https://github.com/GoogleChrome/android-browser-helper)\n- [Trusted Web Activity demos](https://github.com/GoogleChrome/android-browser-helper/tree/master/demos)\n- [Bubblewrap, a NodeJs library / CLI to generate and build Trusted Web Activity projects](https://github.com/GoogleChromeLabs/bubblewrap)\n\nThere are a few things that make Trusted Web Activity different from other ways to open web content from your Android app:\n\n1. Content in a Trusted Web activity is **trusted** -- the app and the site it opens are expected to come from the same developer. (This is verified using [Digital Asset Links](https://developers.google.com/digital-asset-links/v1/getting-started).)\n2. The content rendered in a Trusted Web Activity comes from the **web**: they're rendered by the user's browser, in exactly the same way as a user would see it in their browser except they are run fullscreen. Web content must be accessible and useful in the browser first.\n3. Browsers are also updated independent of Android and your app. That saves on APK size and ensures you can use a modern web runtime. (Note that since Lollipop, WebView has also been updated independent of Android, but there are a [significant number](/about/dashboards) of pre-Lollipop Android users.)\n4. The host app doesn't have direct access to web content in a Trusted Web Activity or any other kind of web state, like cookies and `localStorage`. Nevertheless, you can coordinate with the web content by passing data to and from the page in URLs (e.g. through query parameters and [intent URIs](https://developer.chrome.com/docs/multidevice/android/intents).)\n5. Transitions between web and native content are between **activities**. Each activity (i.e. screen) of your app is either completely provided by the web, or by an Android activity\n\nTo make it easier to test, there are currently no qualifications for content opened in the preview of Trusted Web activities. You can expect, however, that Trusted Web activities need to meet the same [Add to Home Screen](https://web.dev/customize-install#criteria) requirements. You can audit your site for these requirements using the [Lighthouse](https://web.dev/measure/) \"*user can be prompted to Add to Home screen*\" audit.\n\nToday, it is possible for other browsers to implement the same protocol that Trusted Web activities use. While the host app has the final say on what browser gets opened, we recommend the same policy as for Custom Tabs: use the user's default browser, so long as that browser provides the required capabilities.\n\nWhere to go next?\n-----------------\n\nIf you are looking for quickly building an Android app that just starts and opens your PWA, checkout out the [Quick Start Guide](https://developer.chrome.com/docs/android/trusted-web-activity/quick-start).\n\nIf integrating Trusted Web Activity into an existing Android App, the [Integration Guide](https://developer.chrome.com/docs/android/trusted-web-activity/integration-guide) is a good place to get started."]]