Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Pengguna di ponsel Android dapat meminta Asisten Google untuk membagikan konten aplikasi kepada
pengguna lain menggunakan perintah suara seperti "Ok Google, kirim ini kepada Jihan". Berdasarkan
opsi sistem pengguna pertama, Asisten kemudian dapat menggabungkan teks dari
layar atau screenshot perangkat dalam konten yang dibagikan.
Gambar 1. Asisten membagikan foto ke kontak.
Metode berbagi ini sering kali cukup, tetapi pengguna yang menerima konten yang dibagikan
dari aplikasi Anda mungkin tidak masuk kembali ke aplikasi untuk melihat konten. Anda dapat memberikan
informasi terstruktur kepada Asisten tentang konten latar depan saat ini dengan
mengimplementasikan metode onProvideAssistContent().
Proses ini membantu mempertahankan struktur data saat dibagikan kepada pengguna
lain. Pengguna yang menerima konten aplikasi bersama kemudian dapat memiliki deep link atau menerima
konten secara langsung, bukan sebagai teks atau screenshot.
Terapkan onProvideAssistContent() untuk setiap
entity yang dapat dibagikan di aplikasi Anda.
Menyediakan konten ke Asisten
Anda hanya perlu menerapkan onProvideAssistContent() untuk aktivitas aplikasi akhir
dalam alur tugas pengguna setelah memanggil Action Aplikasi. Misalnya, di
Alur GET_ITEM_LIST, implementasikan metode tersebut di layar akhir
menunjukkan daftar item; Anda tidak perlu menerapkannya untuk
produk yang sedang berlangsung atau
layar pratinjau.
overridefunonProvideAssistContent(outContent:AssistContent){super.onProvideAssistContent(outContent)// JSON-LD object based on Schema.org structured dataoutContent.structuredData=JSONObject().put("@type","ItemList").put("name","My Work items").put("url","https://my-notes-and-lists.com/lists/12345a").toString()}
Java
@OverridepublicvoidonProvideAssistContent(AssistContentoutContent){super.onProvideAssistContent(outContent);// JSON-LD object based on Schema.org structured dataoutContent.structuredData=newJSONObject().put("@type","ItemList").put("name","My Work items").put("url","https://my-notes-and-lists.com/lists/12345a").toString();}
Berikan data sebanyak mungkin tentang setiap entity. Kolom berikut
diperlukan:
@type
.name
.url (hanya diperlukan jika konten dapat dialamatkan URL)
Konten dan contoh kode di halaman ini tunduk kepada lisensi yang dijelaskan dalam Lisensi Konten. Java dan OpenJDK adalah merek dagang atau merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-08-08 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-08 UTC."],[],[],null,["# Assistant sharing\n\nUsers on Android phones can ask Google Assistant to share app content with\nanother user using a voice command like *\"Hey Google, send this to Jane.\"* Based\non the first user's system options, Assistant can then incorporate text from\nthe screen or a device screenshot in the shared content.\n**Figure 1.** Assistant shares a photo with a contact.\n\nThis method of sharing is often sufficient, but users who receive content shared\nfrom your app might not re-enter the app to view content. You can provide\nAssistant with structured information about the current foreground content by\nimplementing the [`onProvideAssistContent()`](/reference/android/app/Activity#onProvideAssistContent(android.app.assist.AssistContent)) method.\n\nThis process helps maintain the structure of data as it's shared to another\nuser. Users who receive shared app content can then be deep linked or receive\ncontent directly, instead of as text or as a screenshot.\n\nImplement `onProvideAssistContent()` for any sharable\n[`entity`](/guide/app-actions/legacy/action-schema#entity) in your app.\n\nProvide content to Assistant\n----------------------------\n\nYou only need to implement `onProvideAssistContent()` for the final app activity\nin the user's task flow after invoking the App Action. For example, in a\n`GET_ITEM_LIST` flow, implement the method in the final screen\nshowing the item list; you don't need to implement it for any in-progress or\npreview screens.\n\nProvide contextual information as a [JSON-LD](//json-ld.org/) object\n[using schema.org vocabulary](https://schema.org/docs/documents.html) in the\n`structuredData` field of [`AssistContent`](/reference/android/app/assist/AssistContent). The following code snippet shows\nan example of logging contextual content:\nKotlin \n\n```kotlin\noverride fun onProvideAssistContent(outContent: AssistContent) {\n super.onProvideAssistContent(outContent)\n\n // JSON-LD object based on Schema.org structured data\n outContent.structuredData = JSONObject()\n .put(\"@type\", \"ItemList\")\n .put(\"name\", \"My Work items\")\n .put(\"url\", \"https://my-notes-and-lists.com/lists/12345a\")\n .toString()\n}\n \n```\nJava \n\n```java\n@Override\npublic void onProvideAssistContent(AssistContent outContent) {\n super.onProvideAssistContent(outContent);\n\n // JSON-LD object based on Schema.org structured data\n outContent.structuredData = new JSONObject()\n .put(\"@type\", \"ItemList\")\n .put(\"name\", \"My Work items\")\n .put(\"url\", \"https://my-notes-and-lists.com/lists/12345a\")\n .toString();\n}\n \n```\n\nProvide as much data as possible about each `entity`. The\nfollowing fields are required:\n\n- `@type`\n- `.name`\n- `.url` (only required if the content is URL-addressable)\n\nTo learn more about using `onProvideAssistContent()`, see the\n[Optimizing Contextual Content for the Assistant](/training/articles/assistant) guide."]]