Android APIs
public abstract class

CarrierMessagingService

extends Service
java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ android.service.carrier.CarrierMessagingService

Class Overview

A service that receives calls from the system when new SMS and MMS are sent or received.

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

 <service android:name=".MyMessagingService"
          android:label="@string/service_name"
          android:permission="android.permission.BIND_CARRIER_SERVICES">
     <intent-filter>
         <action android:name="android.service.carrier.CarrierMessagingService" />
     </intent-filter>
 </service>

Summary

Nested Classes
interface CarrierMessagingService.ResultCallback<T> A callback interface used to provide results asynchronously. 
class CarrierMessagingService.SendMmsResult The result of sending an MMS. 
class CarrierMessagingService.SendMultipartSmsResult The result of sending a multipart SMS. 
class CarrierMessagingService.SendSmsResult The result of sending an SMS. 
Constants
int DOWNLOAD_STATUS_ERROR MMS downloading failed.
int DOWNLOAD_STATUS_OK Successfully downloaded an MMS message.
int DOWNLOAD_STATUS_RETRY_ON_CARRIER_NETWORK MMS downloading failed.
int SEND_FLAG_REQUEST_DELIVERY_STATUS Flag to request SMS delivery status report.
int SEND_STATUS_ERROR SMS/MMS sending failed.
int SEND_STATUS_OK Indicates that an SMS or MMS message was successfully sent.
int SEND_STATUS_RETRY_ON_CARRIER_NETWORK SMS/MMS sending failed.
String SERVICE_INTERFACE The Intent that must be declared as handled by the service.
[Expand]
Inherited Constants
From class android.app.Service
From class android.content.Context
From interface android.content.ComponentCallbacks2
Public Constructors
CarrierMessagingService()
Public Methods
IBinder onBind(Intent intent)
Return the communication channel to the service.
void onDownloadMms(Uri contentUri, int subId, Uri location, ResultCallback<Integer> callback)
Override this method to download MMSs received.
void onFilterSms(MessagePdu pdu, String format, int destPort, int subId, ResultCallback<Boolean> callback)
Override this method to filter inbound SMS messages.
void onSendDataSms(byte[] data, int subId, String destAddress, int destPort, int sendSmsFlag, ResultCallback<CarrierMessagingService.SendSmsResult> callback)
Override this method to intercept binary SMSs sent from the device.
void onSendDataSms(byte[] data, int subId, String destAddress, int destPort, ResultCallback<CarrierMessagingService.SendSmsResult> callback)
This method was deprecated in API level 23. Override onSendDataSms(byte[], int, String, int, CarrierMessagingService.ResultCallback) below instead.
void onSendMms(Uri pduUri, int subId, Uri location, ResultCallback<CarrierMessagingService.SendMmsResult> callback)
Override this method to intercept MMSs sent from the device.
void onSendMultipartTextSms(List<String> parts, int subId, String destAddress, int sendSmsFlag, ResultCallback<CarrierMessagingService.SendMultipartSmsResult> callback)
Override this method to intercept long SMSs sent from the device.
void onSendMultipartTextSms(List<String> parts, int subId, String destAddress, ResultCallback<CarrierMessagingService.SendMultipartSmsResult> callback)
This method was deprecated in API level 23. Override onSendMultipartTextSms(List, int, String, CarrierMessagingService.ResultCallback) below instead.
void onSendTextSms(String text, int subId, String destAddress, ResultCallback<CarrierMessagingService.SendSmsResult> callback)
This method was deprecated in API level 23. Override onSendTextSms(String, int, String, CarrierMessagingService.ResultCallback) below instead.
void onSendTextSms(String text, int subId, String destAddress, int sendSmsFlag, ResultCallback<CarrierMessagingService.SendSmsResult> callback)
Override this method to intercept text SMSs sent from the device.
[Expand]
Inherited Methods
From class android.app.Service
From class android.content.ContextWrapper
From class android.content.Context
From class java.lang.Object
From interface android.content.ComponentCallbacks2
From interface android.content.ComponentCallbacks

Constants

public static final int DOWNLOAD_STATUS_ERROR

Added in API level 22

MMS downloading failed. We should not retry via the carrier network.

Constant Value: 2 (0x00000002)

public static final int DOWNLOAD_STATUS_OK

Added in API level 22

Successfully downloaded an MMS message.

Constant Value: 0 (0x00000000)

public static final int DOWNLOAD_STATUS_RETRY_ON_CARRIER_NETWORK

Added in API level 22

MMS downloading failed. We should retry via the carrier network.

Constant Value: 1 (0x00000001)

public static final int SEND_FLAG_REQUEST_DELIVERY_STATUS

Added in API level 23

Flag to request SMS delivery status report.

Constant Value: 1 (0x00000001)

public static final int SEND_STATUS_ERROR

Added in API level 22

SMS/MMS sending failed. We should not retry via the carrier network.

Constant Value: 2 (0x00000002)

public static final int SEND_STATUS_OK

Added in API level 22

Indicates that an SMS or MMS message was successfully sent.

Constant Value: 0 (0x00000000)

public static final int SEND_STATUS_RETRY_ON_CARRIER_NETWORK

Added in API level 22

SMS/MMS sending failed. We should retry via the carrier network.

Constant Value: 1 (0x00000001)

public static final String SERVICE_INTERFACE

Added in API level 22

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

Constant Value: "android.service.carrier.CarrierMessagingService"

Public Constructors

public CarrierMessagingService ()

Added in API level 22

Public Methods

public IBinder onBind (Intent intent)

Added in API level 22

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 The Intent that was used to bind to this service, as given to Context.bindService. Note that any extras that were included with the Intent at that point will not be seen here.
Returns
  • Return an IBinder through which clients can call on to the service.

public void onDownloadMms (Uri contentUri, int subId, Uri location, ResultCallback<Integer> callback)

Added in API level 22

Override this method to download MMSs received.

Parameters
contentUri the content provider URI of the PDU to be downloaded.
subId SMS subscription ID of the SIM
location the URI of the message to be downloaded.
callback result callback. Call with a status code which is one of DOWNLOAD_STATUS_OK, DOWNLOAD_STATUS_RETRY_ON_CARRIER_NETWORK, or DOWNLOAD_STATUS_ERROR.

public void onFilterSms (MessagePdu pdu, String format, int destPort, int subId, ResultCallback<Boolean> callback)

Added in API level 22

Override this method to filter inbound SMS messages.

Parameters
pdu the PDUs of the message
format the format of the PDUs, typically "3gpp" or "3gpp2"
destPort the destination port of a binary SMS, this will be -1 for text SMS
subId SMS subscription ID of the SIM
callback result callback. Call with true to keep an inbound SMS message and deliver to SMS apps, and false to drop the message.

public void onSendDataSms (byte[] data, int subId, String destAddress, int destPort, int sendSmsFlag, ResultCallback<CarrierMessagingService.SendSmsResult> callback)

Added in API level 23

Override this method to intercept binary SMSs sent from the device.

Parameters
data the binary content
subId SMS subscription ID of the SIM
destAddress phone number of the recipient of the message
destPort the destination port
sendSmsFlag Flag for sending SMS. Acceptable values are 0 and SEND_FLAG_REQUEST_DELIVERY_STATUS.
callback result callback. Call with a CarrierMessagingService.SendSmsResult.

public void onSendDataSms (byte[] data, int subId, String destAddress, int destPort, ResultCallback<CarrierMessagingService.SendSmsResult> callback)

Added in API level 22

This method was deprecated in API level 23.
Override onSendDataSms(byte[], int, String, int, CarrierMessagingService.ResultCallback) below instead.

Override this method to intercept binary SMSs sent from the device.

Parameters
data the binary content
subId SMS subscription ID of the SIM
destAddress phone number of the recipient of the message
destPort the destination port
callback result callback. Call with a CarrierMessagingService.SendSmsResult.

public void onSendMms (Uri pduUri, int subId, Uri location, ResultCallback<CarrierMessagingService.SendMmsResult> callback)

Added in API level 22

Override this method to intercept MMSs sent from the device.

Parameters
pduUri the content provider URI of the PDU to send
subId SMS subscription ID of the SIM
location the optional URI to send this MMS PDU. If this is {code null}, the PDU should be sent to the default MMSC URL.
callback result callback. Call with a CarrierMessagingService.SendMmsResult.

public void onSendMultipartTextSms (List<String> parts, int subId, String destAddress, int sendSmsFlag, ResultCallback<CarrierMessagingService.SendMultipartSmsResult> callback)

Added in API level 23

Override this method to intercept long SMSs sent from the device.

Parameters
parts a List of the message parts
subId SMS subscription ID of the SIM
destAddress phone number of the recipient of the message
sendSmsFlag Flag for sending SMS. Acceptable values are 0 and SEND_FLAG_REQUEST_DELIVERY_STATUS.
callback result callback. Call with a CarrierMessagingService.SendMultipartSmsResult.

public void onSendMultipartTextSms (List<String> parts, int subId, String destAddress, ResultCallback<CarrierMessagingService.SendMultipartSmsResult> callback)

Added in API level 22

This method was deprecated in API level 23.
Override onSendMultipartTextSms(List, int, String, CarrierMessagingService.ResultCallback) below instead.

Override this method to intercept long SMSs sent from the device.

Parameters
parts a List of the message parts
subId SMS subscription ID of the SIM
destAddress phone number of the recipient of the message
callback result callback. Call with a CarrierMessagingService.SendMultipartSmsResult.

public void onSendTextSms (String text, int subId, String destAddress, ResultCallback<CarrierMessagingService.SendSmsResult> callback)

Added in API level 22

This method was deprecated in API level 23.
Override onSendTextSms(String, int, String, CarrierMessagingService.ResultCallback) below instead.

Override this method to intercept text SMSs sent from the device.

Parameters
text the text to send
subId SMS subscription ID of the SIM
destAddress phone number of the recipient of the message
callback result callback. Call with a CarrierMessagingService.SendSmsResult.

public void onSendTextSms (String text, int subId, String destAddress, int sendSmsFlag, ResultCallback<CarrierMessagingService.SendSmsResult> callback)

Added in API level 23

Override this method to intercept text SMSs sent from the device.

Parameters
text the text to send
subId SMS subscription ID of the SIM
destAddress phone number of the recipient of the message
sendSmsFlag Flag for sending SMS. Acceptable values are 0 and SEND_FLAG_REQUEST_DELIVERY_STATUS.
callback result callback. Call with a CarrierMessagingService.SendSmsResult.