CarrierMessagingClientService


public class CarrierMessagingClientService
extends Service

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


If the default SMS app has a service that extends this class, the system always tries to bind it so that the process is always running, which allows the app to have a persistent connection to the server.

The service must have an TelephonyManager.ACTION_CARRIER_MESSAGING_CLIENT_SERVICE action in the intent handler, and be protected with Manifest.permission.BIND_CARRIER_MESSAGING_CLIENT_SERVICE. However the service does not have to be exported.

The service must be associated with a non-main process, meaning it must have an android:process tag in its manifest entry.

An app can use PackageManager.setComponentEnabledSetting(ComponentName, int, int) to disable or enable the service. An app should use it to disable the service when it no longer needs to be running.

When the owner process crashes, the service will be re-bound automatically after a back-off.

Note the process may still be killed if the system is under heavy memory pressure, in which case the process will be re-started later.

Example: First, define a subclass in the application:

 public class MyCarrierMessagingClientService extends CarrierMessagingClientService {
 }
 
Then, declare it in its AndroidManifest.xml:
 <service
    android:name=".MyCarrierMessagingClientService"
    android:exported="false"
    android:process=":persistent"
    android:permission="android.permission.BIND_CARRIER_MESSAGING_CLIENT_SERVICE">
    <intent-filter>
        <action android:name="android.telephony.action.CARRIER_MESSAGING_CLIENT_SERVICE" />
    </intent-filter>
 </service>
 

Summary

Inherited constants

Public constructors

CarrierMessagingClientService()

Public methods

final IBinder onBind(Intent intent)

Return the communication channel to the service.

Inherited methods

Public constructors

CarrierMessagingClientService

Added in API level 29
public CarrierMessagingClientService ()

Public methods

onBind

Added in API level 29
public final 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: This value may be null.

Returns
IBinder This value cannot be null.