SDK อุปกรณ์เคลื่อนที่สําหรับ Android

จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ

เพื่อช่วยคุณสร้างแอปพลิเคชัน Android ที่โต้ตอบกับ Matter devices, Google has developed the Google Home Mobile SDK. The Mobile SDK includes two core APIs that allow your apps to to commission and share devices with the Google fabric.

เมื่อเพิ่มอุปกรณ์ลงในผ้า Google แล้ว ผู้ใช้จะควบคุมอุปกรณ์ผ่าน Google Home app (GHA), Android power controls, voice, and Nest touch screen devices. ได้

นอกจากนี้ Mobile SDK ยังให้คุณกําหนดบริการค่าคอมมิชชันที่กําหนดเองที่คุณสามารถใช้เพื่อค่าคอมมิชชันอุปกรณ์ให้กับระบบนิเวศของ Matter เพิ่มเติมได้ด้วย

ผสานรวม SDK อุปกรณ์เคลื่อนที่เข้ากับแอป Android

ในการเริ่มต้นใช้งาน ให้ทําตามขั้นตอนต่อไปนี้

  1. ทําตามวิธีการที่ระบุไว้ในการตั้งค่า Google Play services

  2. เพิ่มทรัพยากร Dependency Play services ในไฟล์ build.gradle ดังนี้

    implementation 'com.google.android.gms:play-services-home:16.0.0-beta1'
    

ตรวจสอบว่านําส่งโมดูล

โมดูล Play services home เป็นพร็อพเพอร์ตี้ที่ไม่บังคับ ดังนั้นฟังก์ชัน Matter จะปรากฏในอุปกรณ์ของผู้ใช้ก็ต่อเมื่อแอปในอุปกรณ์ระบุทรัพยากร Dependency ของโมดูล Play services ที่เหมาะสมในไฟล์ AndroidManifest.xml เท่านั้น

GHA และ Google Home Sample App for Matter both include this module dependency in their manifest. If you are integrating the Mobile SDK into your Android app, to ensure Matter support for users of your app, add the following service block to the application declaration within your AndroidManifest.xml file:

<service android:name="com.google.android.gms.metadata.ModuleDependencies"
    android:enabled="false"
    android:exported="false">
    <intent-filter>
        <action android:name="com.google.android.gms.metadata.MODULE_DEPENDENCIES" />
    </intent-filter>

    <meta-data android:name="home:0:preferred" android:value=""/>
</service>

ตัวเลือกนี้ใช้ได้เฉพาะในอุปกรณ์ Android ที่ใช้ Play services 22.50.14 ขึ้นไป

ดูตัวอย่างการใช้งาน Sample App for Matter ไฟล์ Manifest

ใช้แอปตัวอย่าง Google Home สําหรับ Matter

วิธีการทํางานของ Mobile SDK จากแอป Android ลองใช้ Sample App for Matter ของเรา

ลองใช้ Sample App for Matter

สร้างแอปของคุณเอง

เพื่อช่วยให้คุณเริ่มต้นได้อย่างรวดเร็ว เราได้ทําให้ Sample App for Matter เป็นโอเพนซอร์ส และมี Codelab ที่ใช้ร่วมกัน ซึ่งช่วยให้คุณปรับแต่งโค้ดตัวอย่างสําหรับโปรเจ็กต์ Android ของคุณเองได้

ไปที่ Codelab ของ Sample App for Matter

ทรัพยากร

ดูข้อมูลเพิ่มเติมเกี่ยวกับ Mobile SDK ได้ที่เอกสารอ้างอิง API

หากต้องการทราบว่า SDK นี้จัดการข้อมูลผู้ใช้ปลายทางอย่างไร โปรดอ่านส่วนความปลอดภัยของข้อมูล Google Play SDK บนอุปกรณ์เคลื่อนที่