public abstract class CarrierMessagingService
extends Service
java.lang.Object | ||||
↳ | android.content.Context | |||
↳ | android.content.ContextWrapper | |||
↳ | android.app.Service | |||
↳ | android.service.carrier.CarrierMessagingService |
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>
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 |
RECEIVE_OPTIONS_DEFAULT The default bitmask value passed to the callback of |
int |
RECEIVE_OPTIONS_DROP Used to set the flag in the bitmask passed to the callback of |
int |
RECEIVE_OPTIONS_SKIP_NOTIFY_WHEN_CREDENTIAL_PROTECTED_STORAGE_UNAVAILABLE Used to set the flag in the bitmask passed to the callback of |
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 |
Inherited constants |
---|
![]() android.app.Service
|
![]() android.content.Context
|
![]() 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) This method was deprecated in API level 24. Use |
void |
onReceiveTextSms(MessagePdu pdu, String format, int destPort, int subId, ResultCallback<Integer> callback) Override this method to filter inbound SMS messages. |
void |
onSendDataSms(byte[] data, int subId, String destAddress, int destPort, ResultCallback<CarrierMessagingService.SendSmsResult> callback) This method was deprecated in API level 23. Override |
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 |
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, ResultCallback<CarrierMessagingService.SendMultipartSmsResult> callback) This method was deprecated in API level 23. Override |
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 |
onSendTextSms(String text, int subId, String destAddress, int sendSmsFlag, ResultCallback<CarrierMessagingService.SendSmsResult> callback) Override this method to intercept text SMSs sent from the device. |
void |
onSendTextSms(String text, int subId, String destAddress, ResultCallback<CarrierMessagingService.SendSmsResult> callback) This method was deprecated in API level 23. Override |
Inherited methods |
|
---|---|
![]() android.app.Service
|
|
![]() android.content.ContextWrapper
|
|
![]() android.content.Context
|
|
![]() java.lang.Object
|
|
![]() android.content.ComponentCallbacks2
|
|
![]() android.content.ComponentCallbacks
|
int DOWNLOAD_STATUS_ERROR
MMS downloading failed. We should not retry via the carrier network.
Constant Value: 2 (0x00000002)
int DOWNLOAD_STATUS_OK
Successfully downloaded an MMS message.
Constant Value: 0 (0x00000000)
int DOWNLOAD_STATUS_RETRY_ON_CARRIER_NETWORK
MMS downloading failed. We should retry via the carrier network.
Constant Value: 1 (0x00000001)
int RECEIVE_OPTIONS_DEFAULT
The default bitmask value passed to the callback of onReceiveTextSms(MessagePdu, String, int, int, CarrierMessagingService.ResultCallback
with all RECEIVE_OPTIONS_x
flags cleared to indicate that the message should be kept and a new message notification should be shown.
See also:
Constant Value: 0 (0x00000000)
int RECEIVE_OPTIONS_DROP
Used to set the flag in the bitmask passed to the callback of onReceiveTextSms(MessagePdu, String, int, int, CarrierMessagingService.ResultCallback
to indicate that the inbound SMS should be dropped.
Constant Value: 1 (0x00000001)
int RECEIVE_OPTIONS_SKIP_NOTIFY_WHEN_CREDENTIAL_PROTECTED_STORAGE_UNAVAILABLE
Used to set the flag in the bitmask passed to the callback of onReceiveTextSms(MessagePdu, String, int, int, CarrierMessagingService.ResultCallback
to indicate that a new message notification should not be shown to the user when the credential-encrypted storage of the device is not available before the user unlocks the phone. It is only applicable to devices that support file-based encryption.
Constant Value: 2 (0x00000002)
int SEND_FLAG_REQUEST_DELIVERY_STATUS
Flag to request SMS delivery status report.
Constant Value: 1 (0x00000001)
int SEND_STATUS_ERROR
SMS/MMS sending failed. We should not retry via the carrier network.
Constant Value: 2 (0x00000002)
int SEND_STATUS_OK
Indicates that an SMS or MMS message was successfully sent.
Constant Value: 0 (0x00000000)
int SEND_STATUS_RETRY_ON_CARRIER_NETWORK
SMS/MMS sending failed. We should retry via the carrier network.
Constant Value: 1 (0x00000001)
String SERVICE_INTERFACE
The Intent
that must be declared as handled by the service.
Constant Value: "android.service.carrier.CarrierMessagingService"
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 : 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 | |
---|---|
IBinder |
Return an IBinder through which clients can call on to the service. |
void onDownloadMms (Uri contentUri, int subId, Uri location, ResultCallback<Integer> callback)
Override this method to download MMSs received.
Parameters | |
---|---|
contentUri |
Uri : the content provider URI of the PDU to be downloaded. |
subId |
int : SMS subscription ID of the SIM |
location |
Uri : the URI of the message to be downloaded. |
callback |
ResultCallback : result callback. Call with a status code which is one of DOWNLOAD_STATUS_OK , DOWNLOAD_STATUS_RETRY_ON_CARRIER_NETWORK , or DOWNLOAD_STATUS_ERROR . |
void onFilterSms (MessagePdu pdu, String format, int destPort, int subId, ResultCallback<Boolean> callback)
This method was deprecated in API level 24.
Use onReceiveTextSms(MessagePdu, String, int, int, CarrierMessagingService.ResultCallback
instead.
Override this method to filter inbound SMS messages.
Parameters | |
---|---|
pdu |
MessagePdu : the PDUs of the message |
format |
String : the format of the PDUs, typically "3gpp" or "3gpp2" |
destPort |
int : the destination port of a binary SMS, this will be -1 for text SMS |
subId |
int : SMS subscription ID of the SIM |
callback |
ResultCallback : result callback. Call with true to keep an inbound SMS message and deliver to SMS apps, and false to drop the message. |
void onReceiveTextSms (MessagePdu pdu, String format, int destPort, int subId, ResultCallback<Integer> callback)
Override this method to filter inbound SMS messages.
This method will be called once for every incoming text SMS. You can invoke the callback with a bitmask to tell the platform how to handle the SMS. For a SMS received on a file-based encryption capable device while the credential-encrypted storage is not available, this method will be called for the second time when the credential-encrypted storage becomes available after the user unlocks the phone, if the bit RECEIVE_OPTIONS_DROP
is not set when invoking the callback.
Parameters | |
---|---|
pdu |
MessagePdu : the PDUs of the message |
format |
String : the format of the PDUs, typically "3gpp" or "3gpp2" |
destPort |
int : the destination port of a binary SMS, this will be -1 for text SMS |
subId |
int : SMS subscription ID of the SIM |
callback |
ResultCallback : result callback. Call with a bitmask integer to indicate how the incoming text SMS should be handled by the platform. Use RECEIVE_OPTIONS_DROP and RECEIVE_OPTIONS_SKIP_NOTIFY_WHEN_CREDENTIAL_PROTECTED_STORAGE_UNAVAILABLE to set the flags in the bitmask. |
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.
Override this method to intercept binary SMSs sent from the device.
Parameters | |
---|---|
data |
byte : the binary content |
subId |
int : SMS subscription ID of the SIM |
destAddress |
String : phone number of the recipient of the message |
destPort |
int : the destination port |
callback |
ResultCallback : result callback. Call with a CarrierMessagingService.SendSmsResult . |
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.
Parameters | |
---|---|
data |
byte : the binary content |
subId |
int : SMS subscription ID of the SIM |
destAddress |
String : phone number of the recipient of the message |
destPort |
int : the destination port |
sendSmsFlag |
int : Flag for sending SMS. Acceptable values are 0 and SEND_FLAG_REQUEST_DELIVERY_STATUS . |
callback |
ResultCallback : result callback. Call with a CarrierMessagingService.SendSmsResult . |
void onSendMms (Uri pduUri, int subId, Uri location, ResultCallback<CarrierMessagingService.SendMmsResult> callback)
Override this method to intercept MMSs sent from the device.
Parameters | |
---|---|
pduUri |
Uri : the content provider URI of the PDU to send |
subId |
int : SMS subscription ID of the SIM |
location |
Uri : the optional URI to send this MMS PDU. If this is {code null}, the PDU should be sent to the default MMSC URL. |
callback |
ResultCallback : result callback. Call with a CarrierMessagingService.SendMmsResult . |
void onSendMultipartTextSms (List<String> parts, int subId, String destAddress, ResultCallback<CarrierMessagingService.SendMultipartSmsResult> callback)
This method was deprecated in API level 23.
Override onSendMultipartTextSms(List
below instead.
Override this method to intercept long SMSs sent from the device.
Parameters | |
---|---|
parts |
List : a List of the message parts |
subId |
int : SMS subscription ID of the SIM |
destAddress |
String : phone number of the recipient of the message |
callback |
ResultCallback : result callback. Call with a CarrierMessagingService.SendMultipartSmsResult . |
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.
Parameters | |
---|---|
parts |
List : a List of the message parts |
subId |
int : SMS subscription ID of the SIM |
destAddress |
String : phone number of the recipient of the message |
sendSmsFlag |
int : Flag for sending SMS. Acceptable values are 0 and SEND_FLAG_REQUEST_DELIVERY_STATUS . |
callback |
ResultCallback : result callback. Call with a CarrierMessagingService.SendMultipartSmsResult . |
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.
Parameters | |
---|---|
text |
String : the text to send |
subId |
int : SMS subscription ID of the SIM |
destAddress |
String : phone number of the recipient of the message |
sendSmsFlag |
int : Flag for sending SMS. Acceptable values are 0 and SEND_FLAG_REQUEST_DELIVERY_STATUS . |
callback |
ResultCallback : result callback. Call with a CarrierMessagingService.SendSmsResult . |
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.
Override this method to intercept text SMSs sent from the device.
Parameters | |
---|---|
text |
String : the text to send |
subId |
int : SMS subscription ID of the SIM |
destAddress |
String : phone number of the recipient of the message |
callback |
ResultCallback : result callback. Call with a CarrierMessagingService.SendSmsResult . |