Amazon Developer

as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
Ring
AWS
Documentation
Support
Contact Us
My Cases
Develop
Test
Publish
Monetize
Engage users
Device specifications
Resources
Skip to main content
Amazon Device Messaging (ADM) is a push notification technology that allows your app to interact with your Lambda. Your Lambda will send instructions to your app using ADM. Note that video skills use ADM differently from the most common use cases for ADM. Video skills use ADM only to carry messages from Lambda to your app (in a one-way fashion). For this reason, only the relevant sections from ADM’s documentation are embedded here. If you read ADM’s documentation directly, you will find many other uses and details that might not be relevant to a video skill on Fire TV.

Update Your App Manifest

Updating your AndroidManifest.xml file is the first step in receiving messages sent via ADM. Make the following changes to your existing file:
  1. Open your AndroidManifest.xml file and add the Amazon namespace:
  2. To declare the permissions necessary to support ADM, after the manifest element, add the permission and uses-permission elements.
  3. Explicitly enable ADM and declare whether your app requires ADM (android:required="true") or can work without ADM being present (android:required="false"). If you specify android:required="false", your app must degrade gracefully if ADM is unavailable. In the application node of the manifest, add the amazon:enable-feature element .
  4. Declare a broadcast receiver to handle the REGISTRATION and RECEIVE intents that ADM sends. ADM requires that the receiver be defined in the AndroidManifest.xml file, rather than programmatically. Immediately after amazon:enable-feature add the following elements.
  5. After updating your AndroidManifest.xml file, you can confirm that the changes are correct for ADM by calling ADMManifest.checkManifestAuthoredProperly(). If you receive a java.lang.NoClassDefFoundError: com.amazon.device.messaging.ADM error, check your manifest to verify that you have added the amazon:enable-feature element in the location specified in step 3.
The following code is a complete example of an AndroidManifest.xml file enabled for ADM.

Implement Handling for Registration and Messages

The broadcast receiver declared in your manifest both listens for intents and invokes your app when intents arrive. Your app communicates with the broadcast receiver via the following callback methods defined in the com.amazon.device.messaging.ADMMessageHandlerBase class:
  • onRegistered. Called when the registration ID for the app instance is ready. Your app must transmit this registration ID to your server. Doing so enables your server to send messages to the app instance.
  • onUnregistered. Called if your app instance becomes unregistered from ADM.
  • onRegistrationError. Called if your app’s ADM registration request fails for any reason, such as no Amazon user being signed in to the device.
  • onMessage. Called when the ADM Client delivers a message to your app instance.
Your app must override these callbacks when you implement subclasses of com.amazon.device.messaging.ADMMessageHandlerBase and com.amazon.device.messaging.ADMMessageReceiver, as shown in the following code sample:

Gracefully Degrade If ADM Is Unavailable

In your manifest file, you declare whether your app can (android:required="false") or cannot (android:required="true") work without ADM. If you specify android:required="false", your app must degrade gracefully if ADM is unavailable. Designing your app to accommodate the absence of ADM allows you to build a single APK that can be installed and run on devices that may or may not include ADM. To modify your app to gracefully degrade
  1. Use code similar to the following to check for ADM.
  2. Add the following code to any of your code that requires the ADM library runtime.
  3. In your AndroidManifest.xml file, verify that the application element specifies:

Alternatives to ADM

Instead of using ADM to send instructions from your Lambda function to your app, you can also send actions to your app using your own protocol and cloud service. With this option, you own the delivery of commands to your app. The protocol and characteristics of the communication are entirely up to you and can be managed from your Lambda code or from a service call into your infrastructure. This approach requires an identifier unique to this instance of the application to be provided to the Alexa Client upon initialization. This identifier will be used to target this application instance when a directive is sent to your Lambda code. (If you do not already have an identifier for the app instance or do not wish to pass it to Alexa, consider using ANDROID_ID for this purpose.) If you choose this approach, you will need to work out much of the implementation code on your own. These steps will involve the following:
  • Add Alexa Client Library to your project
  • Pass an application instance identifier to client library at initialization
  • Ensure the application instance identifier is known to your cloud
  • Implement the Lambda function and app communication mechanism as you see fit
  • Complete application integration requirements for Alexa Client Library

Next Steps

Continue on to Step 5: Sign Your App and Configure a Security Profile. (If you run into any issues that prevent you from continuing, see Troubleshooting for Cloudside Integrations.)
Last modified on October 13, 2021