AlternativeMessageTransportService


public abstract class AlternativeMessageTransportService
extends Service

java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ android.service.messaging.AlternativeMessageTransportService


AlternativeMessageTransportService (AMTS) allows the default SMS app to handle the sending of a message over a different transport (e.g. RCS etc.) other than the SMS or MMS. When an SMS or MMS is being sent, the Telephony framework checks if the default SMS app has implemented this service. If so, it binds to the service and requests the SMS app to send it over it's preferred transport.

If the service accepts the upgrade request, the default SMS app is solely responsible for sending the message to the recipient and moving it from the OUTBOX to SENT or FAILED folder.

To extend this class, you must declare the service in your manifest file to require the Manifest.permission.BIND_ALTERNATIVE_MESSAGE_TRANSPORT_SERVICE permission and include an intent filter with the SERVICE_INTERFACE action. For example:

 <service android:name=".MyAlternativeMessageTransportService"
          android:permission="android.permission.BIND_ALTERNATIVE_MESSAGE_TRANSPORT_SERVICE"
          android:exported="true">
     <intent-filter>
         <action android:name="android.service.messaging.AlternativeMessageTransportService"
         />
     </intent-filter>
 </service>
 

Summary

Constants

String SERVICE_INTERFACE

The Intent that must be declared as handled by the service.

int UPGRADE_STATUS_ACCEPTED

Status code when the default SMS app has accepted the message upgrade request and will now attempt to send it as per it's supported transport.

int UPGRADE_STATUS_REJECTED

Status code when the default SMS app could not accept the message upgrade request.

Inherited constants

Public constructors

AlternativeMessageTransportService()

Public methods

final IBinder onBind(Intent intent)

Return the communication channel to the service.

abstract void onMessageUpgradeRequested(Uri contentUri, Consumer<Integer> upgradeStatus)

Called by the service upon receiving a new message upgrade request.

Inherited methods

Constants

SERVICE_INTERFACE

Added in API level 37
public static final String SERVICE_INTERFACE

The Intent that must be declared as handled by the service.

Constant Value: "android.service.messaging.AlternativeMessageTransportService"

UPGRADE_STATUS_ACCEPTED

Added in API level 37
public static final int UPGRADE_STATUS_ACCEPTED

Status code when the default SMS app has accepted the message upgrade request and will now attempt to send it as per it's supported transport.

Constant Value: 1 (0x00000001)

UPGRADE_STATUS_REJECTED

Added in API level 37
public static final int UPGRADE_STATUS_REJECTED

Status code when the default SMS app could not accept the message upgrade request.

Constant Value: 2 (0x00000002)

Public constructors

AlternativeMessageTransportService

public AlternativeMessageTransportService ()

Public methods

onBind

Added in API level 37
public final IBinder onBind (Intent intent)

Return the communication channel to the service. May return null if clients can not bind to the service. The returned IBinder is usually for a complex interface that has been described using aidl.

Note that unlike other application components, calls on to the IBinder interface returned here may not happen on the main thread of the process. More information about the main thread can be found in Processes and Threads.

Parameters
intent Intent: This value may be null.

Returns
IBinder This value may be null.

onMessageUpgradeRequested

Added in API level 37
public abstract void onMessageUpgradeRequested (Uri contentUri, 
                Consumer<Integer> upgradeStatus)

Called by the service upon receiving a new message upgrade request. SMS app will have 10 seconds to respond to the upgrade request with either UPGRADE_STATUS_ACCEPTED or UPGRADE_STATUS_REJECTED. It's not expected to keep running while the message is being sent.

Parameters
contentUri Uri: the content URI of the MMS message.
This value cannot be null.

upgradeStatus Consumer: callback to notify about the upgrade status.
This value cannot be null.