Omówienie zaufanych działań w internecie
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Zaufana aktywność internetowa to nowy sposób otwierania treści aplikacji internetowej, np. progresywnej aplikacji internetowej (PWA), z aplikacji na Androida za pomocą protokołu opartego na kartach niestandardowych.
Uwaga: zaufana aktywność internetowa jest dostępna w Chrome na Androida w wersji 72 lub nowszej.
Szukasz kodu?
Zaufana aktywność internetowa różni się od innych sposobów otwierania treści internetowych z aplikacji na Androida. Oto kilka powodów:
- Treści w ramach zaufanej aktywności w internecie są zaufane – aplikacja i witryna, którą otwiera, powinny pochodzić od tego samego dewelopera. (jest to weryfikowane za pomocą Digital Asset Links).
- Treści renderowane w ramach zaufanej aktywności w internecie pochodzą z sieci: są renderowane przez przeglądarkę użytkownika dokładnie tak samo, jak widzi je użytkownik w swojej przeglądarce, z tym że są wyświetlane na pełnym ekranie. Treści internetowe muszą być przede wszystkim dostępne i przydatne w przeglądarce.
- Przeglądarki są też aktualizowane niezależnie od Androida i Twojej aplikacji. Dzięki temu zmniejsza się rozmiar pliku APK i możesz korzystać z nowoczesnego środowiska uruchomieniowego. (od Lollipop komponent WebView jest aktualizowany niezależnie od Androida, ale spora liczba użytkowników Androida korzysta z wersji Lollipop i starszych).
- Aplikacja hosta nie ma bezpośredniego dostępu do treści internetowych w ramach zaufanej aktywności w internecie ani do żadnego innego stanu przeglądarki, np. plików cookie i
localStorage
. Możesz jednak stosować synchronizację z zawartością w internecie, przekazując dane do i z witryny w adresach URL (np. za pomocą parametrów zapytania i identyfikatorów URI zamiaru).
- Przejścia między treściami internetowymi a treściami natywnymi są działaniami. Każda aktywność (czyli ekran) w aplikacji jest albo całkowicie obsługiwana przez przeglądarkę internetową, albo przez aktywność na Androidzie.
Aby ułatwić testowanie, obecnie nie ma żadnych wymagań dotyczących treści otwieranych w podglądzie zaufanych działań w internecie. Należy jednak pamiętać, że działania w zaufanych witrynach muszą spełniać te same wymagania co dodawanie do ekranu głównego. Aby sprawdzić, czy Twoja witryna spełnia te wymagania, możesz użyć audytu Lighthouse „Użytkownik może otrzymać prośbę o dodanie aplikacji do ekranu głównego”.
Obecnie inne przeglądarki mogą stosować ten sam protokół, którego używają zaufane działania w internecie. Ostateczne decyzje dotyczące tego, która przeglądarka ma się otworzyć, podejmuje aplikacja goszcząca, ale zalecamy stosowanie tych samych zasad co w przypadku kart niestandardowych: używaj domyślnej przeglądarki użytkownika, o ile tylko zapewnia ona wymagane funkcje.
Co dalej?
Jeśli chcesz szybko utworzyć aplikację na Androida, która uruchamia i otwiera Twoją aplikację PWA, zapoznaj się z krótkim przewodnikiem.
Jeśli chcesz zintegrować zaufane działania w internecie z dotychczasową aplikacją na Androida, zacznij od przeczytania przewodnika po integracji.
Treść strony i umieszczone na niej fragmenty kodu podlegają licencjom opisanym w Licencji na treści. Java i OpenJDK są znakami towarowymi lub zastrzeżonymi znakami towarowymi należącymi do firmy Oracle lub jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-27 UTC.
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 2025-07-27 UTC."],[],[],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."]]