“读一读”是 Android 设备上的一项 Google 助理功能,为用户提供了另一种方式来阅读新闻报道和博文等长篇幅 Web 内容。用户可以说出类似“Hey Google, read it”之类的指令,让应用朗读基于网络的内容,突出显示要朗读的字词,以及自动滚动页面。如需详细了解此功能,您还可以参阅有关“读一读”功能产品最新动态的博文。
overridefunonProvideAssistContent(outContent:AssistContent){super.onProvideAssistContent(outContent)// Set the web URI for content to be read from a// WebView, Chrome Custom Tab, or other sourcevalurlString=url.toString()outContent.setWebUri(Uri.parse(urlString))// Create JSON-LD object based on schema.org structured datavalstructuredData=JSONObject().put("@type","Article").put("name","ExampleName of blog post").put("url",outContent.getWebUri()).toString()outContent.setStructuredData(structuredData)}
Java
@OverridepublicvoidonProvideAssistContent(AssistContentoutContent){// Set the web URI for content to be read from a// WebView, Chrome Custom Tab, or other sourceStringurlString=url.toString();outContent.setWebUri(Uri.parse(urlString));try{// Create JSON-LD object based on schema.org structured dataStringstructuredData=newJSONObject().put("@type","Article").put("name","ExampleName of blog post").put("url",outContent.getWebUri()).toString();outContent.setStructuredData(structuredData);}catch(JSONExceptionex){// Handle exceptionLog.e(TAG,ex.getMessage());}super.onProvideAssistContent(outContent);}
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-08。"],[],[],null,["# Read It is a Google Assistant feature available on Android devices that offers\nanother way for users to read long-form web content like news articles and\nblog posts. Users can say something like *\"Hey Google, read it\"* to have an app\nread web-based content out loud, highlight the words being read, and auto-scroll\nthe page. To learn more about this feature, you can also read the\n[Read It product update post](https://www.blog.google/products/assistant/easier-access-web-pages-let-assistant-read-it-aloud/).\n**Figure 1.** Listening to an app read web content out loud.\n\nAndroid apps with web-based content can support Read It by providing information\nto Assistant using 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 with\nAssistant. Users who receive shared app content can then be deep linked or\nreceive content directly, instead of as text or a screenshot.\n\nImplement `onProvideAssistContent()` for any web-based content\nand any sharable [`entity`](/guide/app-actions/legacy/action-schema#entity) in your app.\n\nProvide content to Assistant\n----------------------------\n\nFor Read It to access your content, your app must provide Assistant with\ninformation about the content, like its web URI and some basic context.\nAssistant can then retrieve your content to be read out loud to the user.\n\nFor\nAndroid apps that already implement [web-based content](/guide/webapps) using WebViews or\nChrome Custom Tabs, use the same web URIs for Read It as a\nstarting point.\n\nWhen combining Read It functionality with built-in intents, you only need to\nimplement `onProvideAssistContent()` for the final app activity in the user's\ntask flow after invoking the App Action.\n\nFor example, if your app displays\nnews articles, implement `onProvideAssistContent()` in the final screen\nshowing the article; you don't need to implement it for any in-progress or\npreview screens.\n\nProvide a web URI for your content in the `uri` field of [`AssistContent`](/reference/android/app/assist/AssistContent).\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.\n| **Note:** Read It functionality is not available for content that requires authentication, such as articles locked for users without a subscription.\n\nThe following code snippet shows an example of providing content to Assistant: \n\n### Kotlin\n\n```kotlin\noverride fun onProvideAssistContent(outContent: AssistContent) {\n super.onProvideAssistContent(outContent)\n\n // Set the web URI for content to be read from a\n // WebView, Chrome Custom Tab, or other source\n val urlString = url.toString()\n outContent.setWebUri(Uri.parse(urlString))\n\n // Create JSON-LD object based on schema.org structured data\n val structuredData = JSONObject()\n .put(\"@type\", \"Article\")\n .put(\"name\", \"ExampleName of blog post\")\n .put(\"url\", outContent.getWebUri())\n .toString()\n outContent.setStructuredData(structuredData)\n}\n```\n\n### Java\n\n```java\n@Override\npublic void onProvideAssistContent(AssistContent outContent) {\n\n // Set the web URI for content to be read from a\n // WebView, Chrome Custom Tab, or other source\n String urlString = url.toString();\n outContent.setWebUri(Uri.parse(urlString));\n\n try {\n // Create JSON-LD object based on schema.org structured data\n String structuredData = new JSONObject()\n .put(\"@type\", \"Article\")\n .put(\"name\", \"ExampleName of blog post\")\n .put(\"url\", outContent.getWebUri())\n .toString();\n outContent.setStructuredData(structuredData);\n } catch (JSONException ex) {\n // Handle exception\n Log.e(TAG, ex.getMessage());\n }\n\n super.onProvideAssistContent(outContent);\n}\n```\n\nWhen implementing `onProvideAssistContent()`, provide as much\ndata as possible about each `entity`. The following\nfields are required:\n\n- `@type`\n- `.name`\n- `.url` (only required if the content is URL-addressable)\n\nTo learn more about using [`onProvideAssistContent()`](/reference/android/app/Activity#onProvideAssistContent(android.app.assist.AssistContent)), see the\n[Optimizing Contextual Content for the Assistant](/training/articles/assistant) guide in\nthe Android developer documentation."]]