在範本應用程式中新增對 Android Auto 的支援
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
請詳閱下列資訊,瞭解如何變更應用程式的資訊清單,讓 Android Auto 瞭解應用程式的 CarAppService
並與該服務互動。
宣告 Android Auto 支援
Android Auto 主機會檢查應用程式是否已宣告支援 Android Auto。
如要啟用這項支援功能,請在應用程式的資訊清單中加入下列項目:
<application>
...
<meta-data
android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc"/>
...
</application>
此資訊清單項目參照您透過路徑 AppProjectDirectory/app/src/main/res/xml/automotive_app_desc.xml
所建立的另一個 XML 檔案。您可以在該檔案中宣告應用程式支援的 Android Auto 功能。
使用 車輛專用 Android App Library 的應用程式必須在 automotive_app_desc.xml
檔案中宣告 template
功能:
<automotiveApp>
<uses name="template" />
</automotiveApp>
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-08-27 (世界標準時間)。
[null,null,["上次更新時間:2025-08-27 (世界標準時間)。"],[],[],null,["Review the following information to learn how make changes to your app's manifest\nso that Android Auto can discover and interact with your app's `CarAppService`.\n\nDeclare Android Auto support\n\nThe [Android Auto host](/training/cars/apps#key-terms-concepts) checks whether\nthe app has declared support for [Android Auto](/training/cars#auto).\nTo enable this support, include the following entry in your app's manifest: \n\n \u003capplication\u003e\n ...\n \u003cmeta-data\n android:name=\"com.google.android.gms.car.application\"\n android:resource=\"@xml/automotive_app_desc\"/\u003e\n ...\n \u003c/application\u003e\n\nThis manifest entry refers to another XML file that you create with the\npath \u003cvar translate=\"no\"\u003eAppProjectDirectory\u003c/var\u003e`/app/src/main/res/xml/automotive_app_desc.xml`.\nIn that file, you declare what Android Auto capabilities your app supports.\n\nApps using the [Android for Cars App\nLibrary](/reference/androidx/car/app/package-summary)\nmust declare the `template` capability in the `automotive_app_desc.xml` file: \n\n \u003cautomotiveApp\u003e\n \u003cuses name=\"template\" /\u003e\n \u003c/automotiveApp\u003e"]]