เพิ่มการรองรับ Android Auto ในแอปที่ใช้เทมเพลต
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
อ่านข้อมูลต่อไปนี้เพื่อดูวิธีเปลี่ยนแปลงไฟล์ Manifest ของแอป
เพื่อให้ Android Auto ค้นพบและโต้ตอบกับ CarAppService
ของแอปได้
ประกาศการรองรับ Android Auto
โฮสต์ Android Auto จะตรวจสอบว่าแอปได้ประกาศการรองรับ Android Auto หรือไม่
หากต้องการเปิดใช้การรองรับนี้ ให้ใส่รายการต่อไปนี้ในไฟล์ Manifest ของแอป
<application>
...
<meta-data
android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc"/>
...
</application>
รายการในไฟล์ Manifest นี้อ้างอิงไฟล์ XML อื่นที่คุณสร้างด้วย
พาธ AppProjectDirectory/app/src/main/res/xml/automotive_app_desc.xml
ในไฟล์นั้น คุณจะประกาศความสามารถของ Android Auto ที่แอปของคุณรองรับ
แอปที่ใช้ไลบรารีแอป Android สำหรับรถยนต์
ต้องประกาศความสามารถ template
ในไฟล์ automotive_app_desc.xml
ดังนี้
<automotiveApp>
<uses name="template" />
</automotiveApp>
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-09-03 UTC
[[["เข้าใจง่าย","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"]],["อัปเดตล่าสุด 2025-09-03 UTC"],[],[],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"]]