Trusted Web Activity 概览
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Trusted Web Activity 是一种新的方式,可让您使用基于自定义标签页的协议,从 Android 应用打开您的 Web 应用内容(例如您的渐进式 Web 应用 [PWA])。
注意:Android 版 Chrome 72 及更高版本支持 Trusted Web Activity。
找不到验证码?
Trusted Web Activity 与从 Android 应用打开网络内容的其他方式存在一些不同之处:
- Trusted Web activity 中的内容是可信的,即应用及其打开的网站应来自同一开发者。(此信息使用 Digital Asset Links 进行验证。)
- 可信 Web 活动中呈现的内容来自网络:它们由用户的浏览器呈现,呈现方式与用户在浏览器中看到的内容完全相同,只不过是全屏运行。网页内容首先必须在浏览器中可访问且实用。
- 浏览器也会独立于 Android 和您的应用进行更新。这有助于缩减 APK 大小,并确保您可以使用现代 Web 运行时。(请注意,自 Lollipop 起,WebView 也独立于 Android 进行更新,但有大量 Android Lollipop 之前的用户。)
- 托管应用无法直接访问可信 Web 活动中的 Web 内容或任何其他类型的 Web 状态,例如 Cookie 和
localStorage
。不过,您可以通过在网址中传递数据(例如通过查询参数和 intent URI)来与网页内容协调。
- 网页内容和原生内容之间的转换是指在 activity 之间进行的转换。应用的每个 activity(即屏幕)均由网站或 Android activity 完全提供
为了简化测试流程,目前在 Trusted Web Activity 预览中打开的内容没有任何资格要求。不过,您可以预料到,可信 Web 活动需要满足相同的添加到主屏幕要求。您可以使用 Lighthouse 的“用户可以看到‘添加到主屏幕’提示”审核来检查您的网站是否符合这些要求。
目前,其他浏览器可以实现 Trusted Web activity 使用的相同协议。虽然托管应用对要打开的浏览器拥有最终决定权,但我们建议采用与自定义标签页相同的政策:使用用户的默认浏览器(前提是该浏览器提供所需功能)。
接下来该怎么做?
如果您希望快速构建一个仅用于启动和打开 PWA 的 Android 应用,请参阅快速入门指南。
如果要将 Trusted Web Activity 集成到现有 Android 应用中,不妨先参阅集成指南。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):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."]]