自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
有关防止驾驶员分心的准则
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
当 Android Automotive 应用遵循下文所述的《有关防止驾驶员分心的准则》(DDG) 时,应用在车辆移动时可以在 HU 上运行。DDG 包含由 Google 提供的基准建议,旨在降低对驾驶员的干扰。
符合《有关防止驾驶员分心的准则》的应用可以标记为“经过防分心优化”。本页面将详细介绍如何将应用标记为“经过防分心优化”,以便 Android 平台能够让应用在用户体验受限的状态下运行。如需详细了解:
经过防分心优化的应用
应用可以将特定 activity 标记为“经过防分心优化”。如需将整个应用指定为“经过防分心优化”,其所有 activity 都必须遵守有关防止驾驶员分心的准则。当车辆的驾驶状态变为启用“用户体验限制”的状态时:
- 当前前台 activity 必须在清单中标记为“经过防分心优化”,才能继续运行。
- 启动新 activity 时,新 activity 必须在清单中标记为“经过防分心优化”,才被允许启动。
平台负责检查清单,并仅允许经过防分心优化的 activity 以受限状态运行。
注意:平台无法检测或强制应用对限制的实际遵守;它只能检查清单中应用的声明。在 Google Play 审核流程中,会强制要求遵循这些有关防止驾驶员分心的准则。
并非所有应用 activity 都需要进行防分心优化。相比于受限状态,应用可以为不受限制的状态(例如车辆停放时)提供不同的用户体验。因此,应用可以将特定 activity 标记为“经过防分心优化”,方法是将以下元数据添加到应用的 AndroidManifest.xml
文件的 <activity>
元素中:
<activity android:name=".DistractionOptimizedMainActivity"....>
....
<meta-data android:name="distractionOptimized" android:value="true"/>
</activity>
如果应用提供要在受限状态下运行的 activity,则必须在清单中声明该信息。平台只会先检查声明的信息,然后确定允许(或不允许)activity 在受限状态下运行。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[[["易于理解","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-07-27。"],[],[],null,["# Driver Distraction Guidelines\n\nWhen Android Automotive apps follow the *Driver Distraction Guidelines* described\nbelow, the apps can run on the HU when a vehicle is moving. DDG consists of baseline\nrecommendations provided by Google and are intended to reduce driver distraction.\n\nApps that meet the Driver Distraction Guidelines can be tagged as\n*Distraction Optimized* . This page details how apps *must* be tagged\nas Distraction Optimized so that the Android platform can enable the apps to run in the User\nExperience Restricted state. To learn more about:\n\n- Car user experience restrictions, see [Car User Experience\n Restrictions](/docs/automotive/driver_distraction/car_uxr).\n- Using car driving state, see [Consuming Car Driving State and\n UX Restrictions](/docs/automotive/driver_distraction/consume).\n\nDistraction Optimized apps\n--------------------------\n\nAn app can tag a specific activity to be Distraction Optimized. For an entire app to\nbe designated as Distraction Optimized, all its activities must adhere to the driver distraction\nguidelines. When the driving state of a vehicle changes to a state in which the UX restrictions are\nactive:\n\n- Current foreground activity can continue to run only when it is tagged as Distraction Optimized in the manifest.\n- When launching a new activity, the new activity is permitted only when it is tagged as Distraction Optimized in the manifest.\n\nThe platform is responsible for checking the manifest and allowing only Distraction Optimized\nactivities to run in a restricted state.\n\n**Note:** The platform can't detect or enforce an app's actual\nadherence to the restrictions; it can only check an app's declaration in the manifest. Adherence to\nthese driver distraction guidelines is enforced during the Google Play review process.\n\nNot all app activities need be Distraction Optimized. An app can provide\ndifferent user experiences for an unrestricted state (for example, when the vehicle is parked)\nversus a more restricted state. As a result, an app can tag a specific activity to be\nDistraction Optimized by adding the following metadata to the `\u003cactivity\u003e` element\nin the `AndroidManifest.xml` file for the app: \n\n```\n\u003cactivity android:name=\".DistractionOptimizedMainActivity\"....\u003e\n....\n\u003cmeta-data android:name=\"distractionOptimized\" android:value=\"true\"/\u003e\n\u003c/activity\u003e\n```\n\nApps that offer activities designed to run in a restricted state must declare that information in\nthe manifest. The platform looks only at the declared information before determining if the activity\ncan be permitted to run (or not) in the restricted state."]]