在手机上授予权限
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
当用户尝试打开您的应用但缺少必要的权限时,请使用消息模板告诉他们需要授予权限。
在 Android Auto 中,如果您已经使用了请求权限中所述的方法,只要用户没有驾驶,权限对话框就会在手机上打开(如需了解技术详情,请访问处理用户输入)。在这种情况下,请提供将用户定向到手机的消息框。然后,在授予权限后,刷新车载屏幕,使用户不会返回消息模板。
示例流程
用户操作 |
执行操作的位置 |
操作之后的步数 |
用户打开应用。 |
在着陆页模板(未显示)中 |
1 |
用户选择授予应用权限的选项,然后查看确认消息框。 |
首先,使用带有两个按钮的消息模板,以便用户有机会授予他们所需的权限:

然后,在同一消息模板上显示消息框,以将用户定向到手机:

|
2 |
用户在手机上授予权限。
|
无模板,因为此操作会在用户手机上发生:
|
2(在车载设备上未与应用互动) |
用户授予权限后,应用会返回着陆页模板。 |
着陆页模板;在本例中为“地点列表(导航)”模板:
|
1(步数重置) |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003eWhen users lack necessary permissions, use the Message template to inform them and provide an option to grant permissions.\u003c/p\u003e\n"],["\u003cp\u003eIn Android Auto, the permission dialog opens on the user's phone when they are not driving, requiring a toast to direct them.\u003c/p\u003e\n"],["\u003cp\u003eAfter permissions are granted, refresh the car screen to transition from the Message template to the intended content, such as the landing template.\u003c/p\u003e\n"],["\u003cp\u003eThe app's flow involves requesting permissions on the car screen, user confirmation on their phone, and returning to the app's landing template.\u003c/p\u003e\n"]]],[],null,["# Grant permissions on phone\n\n\u003cbr /\u003e\n\nWhen users try to open your app and lack necessary permissions, use the Message\ntemplate to tell them they need to grant permissions.\n\nIn Android Auto, if you have used the method described in\n[Request Permissions](https://developer.android.com/training/cars/apps#permissions),\nthe permissions dialog will open on the phone, as long as the user is not\ndriving (for technical details, visit\n[Handle user input](https://developer.android.com/training/cars/apps#handle-user-input)).\nIn this case, provide a toast directing the user to the phone. Then, after\npermissions are granted, refresh the car screen so the user doesn't return to\nthe Message template. \nFirst, the app requests permissions on the car screen... \n...and then the user confirms permissions on their phone when not\ndriving.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nSample flow\n-----------\n\n| User action | Where action is performed | Step count after action |\n|--------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|\n| The user opens the app. | On your landing template (not shown) | 1 |\n| The user selects the option to grant app permissions, then reviews the confirmation toast. | First, use the Message template with two buttons to allow users the chance to grant the permissions that they need: Then, display a toast on that same Message template to direct the user to their phone: | 2 |\n| The user grants permission on their phone. | No template, as this action occurs on the user's phone: | 2 (no interaction with app in car) |\n| After the user grants permissions, the app returns to the landing template. | Landing template; in this case, the Place List (navigation) template: | 1 (step count resets) |"]]