Added in API level 37

AlternativeMessageTransportService


abstract class AlternativeMessageTransportService : Service
kotlin.Any
   ↳ 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 android.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
static String

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

static Int

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.

static Int

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

Inherited constants
Public constructors

Public methods
IBinder?
onBind(intent: Intent?)

Return the communication channel to the service.

abstract Unit
onMessageUpgradeRequested(contentUri: Uri, upgradeStatus: Consumer<Int!>)

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

Inherited functions

Constants

SERVICE_INTERFACE

Added in API level 37
static val SERVICE_INTERFACE: String

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

Value: "android.service.messaging.AlternativeMessageTransportService"

UPGRADE_STATUS_ACCEPTED

Added in API level 37
static val UPGRADE_STATUS_ACCEPTED: Int

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.

Value: 1

UPGRADE_STATUS_REJECTED

Added in API level 37
static val UPGRADE_STATUS_REJECTED: Int

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

Value: 2

Public constructors

AlternativeMessageTransportService

AlternativeMessageTransportService()

Public methods

onBind

Added in API level 37
fun onBind(intent: Intent?): IBinder?

Return the communication channel to the service. May return null if clients can not bind to the service. The returned android.os.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.
Return
IBinder? This value may be null.

onMessageUpgradeRequested

Added in API level 37
abstract fun onMessageUpgradeRequested(
    contentUri: Uri,
    upgradeStatus: Consumer<Int!>
): Unit

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<Int!>: callback to notify about the upgrade status.
This value cannot be null.