Most visited

Recently visited

Added in API level 22

CarrierMessagingService

public abstract class CarrierMessagingService
extends Service

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


发送或接收新SMS和MMS时接收系统呼叫的服务。

要扩展此类,您必须在清单文件中声明服务并使用BIND_CARRIER_SERVICES权限,并包含一个包含SERVICE_INTERFACE操作的意向过滤器。 例如:

 <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>

用于异步提供结果的回调接口。

class CarrierMessagingService.SendMmsResult

发送彩信的结果。

class CarrierMessagingService.SendMultipartSmsResult

发送多部分SMS的结果。

class CarrierMessagingService.SendSmsResult

发送短信的结果。

Constants

int DOWNLOAD_STATUS_ERROR

彩信下载失败。

int DOWNLOAD_STATUS_OK

成功下载彩信。

int DOWNLOAD_STATUS_RETRY_ON_CARRIER_NETWORK

彩信下载失败。

int RECEIVE_OPTIONS_DEFAULT

传递给回调 onReceiveTextSms(MessagePdu, String, int, int, CarrierMessagingService.ResultCallback ) 的所有 RECEIVE_OPTIONS_x标志的默认位掩码值将被清除,以指示应保留该消息并应显示新的消息通知。

int RECEIVE_OPTIONS_DROP

用于设置传递给回调 onReceiveTextSms(MessagePdu, String, int, int, CarrierMessagingService.ResultCallback ) 的位掩码中的标志,以指示应丢弃入站SMS。

int RECEIVE_OPTIONS_SKIP_NOTIFY_WHEN_CREDENTIAL_PROTECTED_STORAGE_UNAVAILABLE

用于设置传递给 onReceiveTextSms(MessagePdu, String, int, int, CarrierMessagingService.ResultCallback ) 回调的位掩码中的标志,以指示在用户解锁手机前设备的凭证加密存储不可用时,不应向用户显示新消息通知。

int SEND_FLAG_REQUEST_DELIVERY_STATUS

标记以请求SMS传递状态报告。

int SEND_STATUS_ERROR

短信/彩信发送失败。

int SEND_STATUS_OK

表示SMS或MMS消息已成功发送。

int SEND_STATUS_RETRY_ON_CARRIER_NETWORK

短信/彩信发送失败。

String SERVICE_INTERFACE

Intent必须声明为由服务处理。

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)

将通信信道返回给服务。

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

重写此方法以下载收到的MMS。

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

此方法在API级别24中已弃用。请改为使用onReceiveTextSms(MessagePdu, String, int, int, CarrierMessagingService.ResultCallback )

void onReceiveTextSms(MessagePdu pdu, String format, int destPort, int subId, ResultCallback<Integer> callback)

重写此方法以过滤入站SMS消息。

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

此方法在API级别23中已弃用。请onSendDataSms(byte[], int, String, int, CarrierMessagingService.ResultCallback ) 在下面覆盖onSendDataSms(byte[], int, String, int, CarrierMessagingService.ResultCallback )

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

重写此方法以拦截从设备发送的二进制SMS。

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

重写此方法以拦截从设备发送的MMS。

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

此方法在API级别23中已弃用。请onSendMultipartTextSms(List , int, String, CarrierMessagingService.ResultCallback ) 在下面覆盖onSendMultipartTextSms(List , int, String, CarrierMessagingService.ResultCallback )

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

重写此方法以拦截从设备发送的长期SMS。

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

重写此方法以拦截从设备发送的文本SMS。

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

此方法在API级别23中已弃用。请onSendTextSms(String, int, String, CarrierMessagingService.ResultCallback ) 在下面覆盖onSendTextSms(String, int, String, CarrierMessagingService.ResultCallback )

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

DOWNLOAD_STATUS_ERROR

Added in API level 22
int DOWNLOAD_STATUS_ERROR

彩信下载失败。 我们不应该通过运营商网络重试。

常量值:2(0x00000002)

DOWNLOAD_STATUS_OK

Added in API level 22
int DOWNLOAD_STATUS_OK

成功下载彩信。

常量值:0(0x00000000)

DOWNLOAD_STATUS_RETRY_ON_CARRIER_NETWORK

Added in API level 22
int DOWNLOAD_STATUS_RETRY_ON_CARRIER_NETWORK

彩信下载失败。 我们应该通过运营商网络重试。

常数值:1(0x00000001)

RECEIVE_OPTIONS_DEFAULT

Added in API level 24
int RECEIVE_OPTIONS_DEFAULT

传递给 onReceiveTextSms(MessagePdu, String, int, int, CarrierMessagingService.ResultCallback ) 回调的默认位掩码值(全部为 RECEIVE_OPTIONS_x标志)将被清除,以指示应保留该消息并应显示新的消息通知。

也可以看看:

常量值:0(0x00000000)

RECEIVE_OPTIONS_DROP

Added in API level 24
int RECEIVE_OPTIONS_DROP

用于设置传递给回调 onReceiveTextSms(MessagePdu, String, int, int, CarrierMessagingService.ResultCallback ) 的位掩码中的标志,以指示应丢弃入站SMS。

常数值:1(0x00000001)

RECEIVE_OPTIONS_SKIP_NOTIFY_WHEN_CREDENTIAL_PROTECTED_STORAGE_UNAVAILABLE

Added in API level 24
int RECEIVE_OPTIONS_SKIP_NOTIFY_WHEN_CREDENTIAL_PROTECTED_STORAGE_UNAVAILABLE

用于设置传递给onReceiveTextSms(MessagePdu, String, int, int, CarrierMessagingService.ResultCallback ) 回调的位掩码中的标志,以指示在用户解锁手机之前设备的凭证加密存储不可用时,不应向用户显示新消息通知。 它仅适用于支持基于文件的加密的设备。

常量值:2(0x00000002)

SEND_FLAG_REQUEST_DELIVERY_STATUS

Added in API level 23
int SEND_FLAG_REQUEST_DELIVERY_STATUS

标记以请求SMS传递状态报告。

常数值:1(0x00000001)

SEND_STATUS_ERROR

Added in API level 22
int SEND_STATUS_ERROR

短信/彩信发送失败。 我们不应该通过运营商网络重试。

常量值:2(0x00000002)

SEND_STATUS_OK

Added in API level 22
int SEND_STATUS_OK

表示SMS或MMS消息已成功发送。

常量值:0(0x00000000)

SEND_STATUS_RETRY_ON_CARRIER_NETWORK

Added in API level 22
int SEND_STATUS_RETRY_ON_CARRIER_NETWORK

短信/彩信发送失败。 我们应该通过运营商网络重试。

常数值:1(0x00000001)

SERVICE_INTERFACE

Added in API level 22
String SERVICE_INTERFACE

Intent必须声明为由服务处理。

常量值:“android.service.carrier.CarrierMessagingService”

Public constructors

CarrierMessagingService

Added in API level 22
CarrierMessagingService ()

Public methods

onBind

Added in API level 22
IBinder onBind (Intent intent)

将通信信道返回给服务。 如果客户端无法绑定到服务,可能会返回null。 返回IBinder通常是一个复杂的界面已经described using aidl

请注意,与其他应用程序组件不同,此处返回的IBinder接口调用可能不会发生在进程的主线程上 有关主线程的更多信息可以在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.

onDownloadMms

Added in API level 22
void onDownloadMms (Uri contentUri, 
                int subId, 
                Uri location, 
                ResultCallback<Integer> callback)

重写此方法以下载收到的MMS。

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.

onFilterSms

Added in API level 22
void onFilterSms (MessagePdu pdu, 
                String format, 
                int destPort, 
                int subId, 
                ResultCallback<Boolean> callback)

此方法在API级别24中已弃用。
改为使用onReceiveTextSms(MessagePdu, String, int, int, CarrierMessagingService.ResultCallback )

重写此方法以过滤入站SMS消息。

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.

onReceiveTextSms

Added in API level 24
void onReceiveTextSms (MessagePdu pdu, 
                String format, 
                int destPort, 
                int subId, 
                ResultCallback<Integer> callback)

重写此方法以过滤入站SMS消息。

对于每个传入的文本SMS,此方法将被调用一次。 您可以使用位掩码调用回调函数以告知平台如何处理SMS。 对于凭证加密存储不可用时在基于文件的可加密存储设备上接收的SMS,将在用户解锁手机后凭证加密存储变为可用时再次调用此方法(如果位RECEIVE_OPTIONS_DROP在调用回调时未设置。

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.

onSendDataSms

Added in API level 22
void onSendDataSms (byte[] data, 
                int subId, 
                String destAddress, 
                int destPort, 
                ResultCallback<CarrierMessagingService.SendSmsResult> callback)

此方法在API级别23中已弃用。
onSendDataSms(byte[], int, String, int, CarrierMessagingService.ResultCallback ) 在下面覆盖onSendDataSms(byte[], int, String, int, CarrierMessagingService.ResultCallback )

重写此方法以拦截从设备发送的二进制SMS。

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.

onSendDataSms

Added in API level 23
void onSendDataSms (byte[] data, 
                int subId, 
                String destAddress, 
                int destPort, 
                int sendSmsFlag, 
                ResultCallback<CarrierMessagingService.SendSmsResult> callback)

重写此方法以拦截从设备发送的二进制SMS。

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.

onSendMms

Added in API level 22
void onSendMms (Uri pduUri, 
                int subId, 
                Uri location, 
                ResultCallback<CarrierMessagingService.SendMmsResult> callback)

重写此方法以拦截从设备发送的MMS。

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.

onSendMultipartTextSms

Added in API level 22
void onSendMultipartTextSms (List<String> parts, 
                int subId, 
                String destAddress, 
                ResultCallback<CarrierMessagingService.SendMultipartSmsResult> callback)

此方法在API级别23中已弃用。
onSendMultipartTextSms(List , int, String, CarrierMessagingService.ResultCallback ) 在下面覆盖onSendMultipartTextSms(List , int, String, CarrierMessagingService.ResultCallback )

重写此方法以拦截从设备发送的长期SMS。

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.

onSendMultipartTextSms

Added in API level 23
void onSendMultipartTextSms (List<String> parts, 
                int subId, 
                String destAddress, 
                int sendSmsFlag, 
                ResultCallback<CarrierMessagingService.SendMultipartSmsResult> callback)

重写此方法以拦截从设备发送的长期SMS。

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.

onSendTextSms

Added in API level 23
void onSendTextSms (String text, 
                int subId, 
                String destAddress, 
                int sendSmsFlag, 
                ResultCallback<CarrierMessagingService.SendSmsResult> callback)

重写此方法以拦截从设备发送的文本SMS。

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.

onSendTextSms

Added in API level 22
void onSendTextSms (String text, 
                int subId, 
                String destAddress, 
                ResultCallback<CarrierMessagingService.SendSmsResult> callback)

此方法在API级别23中已弃用。
onSendTextSms(String, int, String, CarrierMessagingService.ResultCallback ) 在下面覆盖onSendTextSms(String, int, String, CarrierMessagingService.ResultCallback )

重写此方法以拦截从设备发送的文本SMS。

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.

Hooray!