To help you build Android applications that interact with Matter devices, Google has developed the Google Home Mobile SDK. The Mobile SDK includes two core APIs that allow your apps to commission and share devices with the Google fabric.
Once a device is added to the Google fabric, your users can control their devices through the Google Home app (GHA), Android power controls, voice, and Nest touch screen devices.
The Mobile SDK also allows you to define a custom commissioning service that you can use to commission devices to additional Matter ecosystems.
Integrate the Mobile SDK into your Android app
To get started, complete the following steps:
Follow the instructions provided at Set up Google Play services.
Add the Play services dependency to your
build.gradle
file:implementation 'com.google.android.gms:play-services-home:16.0.0-beta1'
Ensure module delivery
The Play services home
module is optional, and thus
Matter functionality will only be present on a user's
device if an app on the device specifies the appropriate
Play services module dependency in its AndroidManifest.xml
file.
The GHA and 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>
This is only supported for Android devices running Play services 22.50.14 or higher.
See the Sample App for Matter's manifest for an example implementation.
You can check the Home module availability at runtime by using
ModuleInstallClient
. See the
Ensuring API availability with ModuleInstallClient
page for more information.
Calling other Android apps
If you are using Android 11 or higher, you need to include the following
queries
block in the AndroidManifest.xml
so that your app can make calls to
other apps.
<queries>
<!-- For GMS Core/Play service -->
<package android:name="com.google.android.gms" />
<package android:name="com.android.vending" />
<!-- End of GMS Core/Play service-->
</queries>
For more information, see the Package visibility filtering on Android article.
Use the Google Home Sample App for Matter
To learn how the Mobile SDK works from an Android app, try our Sample App for Matter.
Build your own app
To help you get started fast, we've open-sourced the Sample App for Matter and provided a companion codelab, allowing you to customize our sample code for your own Android projects.
Go to the Sample App for Matter codelab
Resources
To learn more about the Mobile SDK, refer to the API Reference.
To learn how this SDK handles end-user data, refer to the Home Mobile SDK Google Play Data Safety Section