FileDocCategorySizeDatePackage
CarrierMessagingService.javaAPI DocAndroid 5.1 API15943Thu Mar 12 22:22:10 GMT 2015android.service.carrier

CarrierMessagingService

public abstract class CarrierMessagingService extends android.app.Service
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 {@link android.Manifest.permission#BIND_CARRIER_MESSAGING_SERVICE} permission and include an intent filter with the {@link #SERVICE_INTERFACE} action. For example:

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

Fields Summary
public static final String
SERVICE_INTERFACE
The {@link android.content.Intent} that must be declared as handled by the service.
public static final int
SEND_STATUS_OK
Indicates that an SMS or MMS message was successfully sent.
public static final int
SEND_STATUS_RETRY_ON_CARRIER_NETWORK
SMS/MMS sending failed. We should retry via the carrier network.
public static final int
SEND_STATUS_ERROR
SMS/MMS sending failed. We should not retry via the carrier network.
public static final int
DOWNLOAD_STATUS_OK
Successfully downloaded an MMS message.
public static final int
DOWNLOAD_STATUS_RETRY_ON_CARRIER_NETWORK
MMS downloading failed. We should retry via the carrier network.
public static final int
DOWNLOAD_STATUS_ERROR
MMS downloading failed. We should not retry via the carrier network.
private final ICarrierMessagingWrapper
mWrapper
Constructors Summary
Methods Summary
public android.os.IBinderonBind(android.content.Intent intent)

        if (!SERVICE_INTERFACE.equals(intent.getAction())) {
            return null;
        }
        return mWrapper;
    
public voidonDownloadMms(android.net.Uri contentUri, int subId, android.net.Uri location, android.service.carrier.CarrierMessagingService$ResultCallback callback)
Override this method to download MMSs received.

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

        // optional
        try {
            callback.onReceiveResult(DOWNLOAD_STATUS_RETRY_ON_CARRIER_NETWORK);
        } catch (RemoteException ex) {
        }
    
public voidonFilterSms(MessagePdu pdu, java.lang.String format, int destPort, int subId, android.service.carrier.CarrierMessagingService$ResultCallback callback)
Override this method to filter inbound SMS messages.

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


                                                                                            
             
                 
        // optional
        try {
            callback.onReceiveResult(true);
        } catch (RemoteException ex) {
        }
    
public voidonSendDataSms(byte[] data, int subId, java.lang.String destAddress, int destPort, android.service.carrier.CarrierMessagingService$ResultCallback callback)
Override this method to intercept binary SMSs sent from the device.

param
data the binary content
param
subId SMS subscription ID of the SIM
param
destAddress phone number of the recipient of the message
param
destPort the destination port
param
callback result callback. Call with a {@link SendSmsResult}.

        // optional
        try {
            callback.onReceiveResult(new SendSmsResult(SEND_STATUS_RETRY_ON_CARRIER_NETWORK, 0));
        } catch (RemoteException ex) {
        }
    
public voidonSendMms(android.net.Uri pduUri, int subId, android.net.Uri location, android.service.carrier.CarrierMessagingService$ResultCallback callback)
Override this method to intercept MMSs sent from the device.

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

        // optional
        try {
            callback.onReceiveResult(new SendMmsResult(SEND_STATUS_RETRY_ON_CARRIER_NETWORK, null));
        } catch (RemoteException ex) {
        }
    
public voidonSendMultipartTextSms(java.util.List parts, int subId, java.lang.String destAddress, android.service.carrier.CarrierMessagingService$ResultCallback callback)
Override this method to intercept long SMSs sent from the device.

param
parts a {@link List} of the message parts
param
subId SMS subscription ID of the SIM
param
destAddress phone number of the recipient of the message
param
callback result callback. Call with a {@link SendMultipartSmsResult}.

        // optional
        try {
            callback.onReceiveResult(
                    new SendMultipartSmsResult(SEND_STATUS_RETRY_ON_CARRIER_NETWORK, null));
        } catch (RemoteException ex) {
        }
    
public voidonSendTextSms(java.lang.String text, int subId, java.lang.String destAddress, android.service.carrier.CarrierMessagingService$ResultCallback callback)
Override this method to intercept text SMSs sent from the device.

param
text the text to send
param
subId SMS subscription ID of the SIM
param
destAddress phone number of the recipient of the message
param
callback result callback. Call with a {@link SendSmsResult}.

        // optional
        try {
            callback.onReceiveResult(new SendSmsResult(SEND_STATUS_RETRY_ON_CARRIER_NETWORK, 0));
        } catch (RemoteException ex) {
        }