Skip to content

Most visited

Recently visited

navigation

VisualVoicemailService

public abstract class VisualVoicemailService
extends Service

java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ android.telephony.VisualVoicemailService


This service is implemented by dialer apps that wishes to handle OMTP or similar visual voicemails. Telephony binds to this service when the cell service is first connected, a visual voicemail SMS has been received, or when a SIM has been removed. Telephony will only bind to the default dialer for such events (See getDefaultDialerPackage()). The CarrierMessagingService precedes the VisualVoicemailService in the SMS filtering chain and may intercept the visual voicemail SMS before it reaches this service.

To extend this class, The service must be declared in the manifest file with the BIND_VISUAL_VOICEMAIL_SERVICE permission and include an intent filter with the SERVICE_INTERFACE action.

Below is an example manifest registration for a VisualVoicemailService.

 <service android:name="your.package.YourVisualVoicemailServiceImplementation"
          android:permission="android.permission.BIND_VISUAL_VOICEMAIL_SERVICE">
      <intent-filter>
          <action android:name="android.telephony.VisualVoicemailService"/>
      </intent-filter>
 </service>
 
 

Summary

Nested classes

class VisualVoicemailService.VisualVoicemailTask

Represents a visual voicemail event which needs to be handled. 

Constants

String SERVICE_INTERFACE

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

Inherited constants

From class android.app.Service
From class android.content.Context
From interface android.content.ComponentCallbacks2

Public constructors

VisualVoicemailService()

Public methods

IBinder onBind(Intent intent)

Return the communication channel to the service.

abstract void onCellServiceConnected(VisualVoicemailService.VisualVoicemailTask task, PhoneAccountHandle phoneAccountHandle)

Called when the cellular service is connected on a PhoneAccountHandle for the first time, or when the carrier config has changed.

abstract void onSimRemoved(VisualVoicemailService.VisualVoicemailTask task, PhoneAccountHandle phoneAccountHandle)

Called when a SIM is removed.

abstract void onSmsReceived(VisualVoicemailService.VisualVoicemailTask task, VisualVoicemailSms sms)

Called when a SMS matching the VisualVoicemailSmsFilterSettings set by setSmsFilterSettings(Context, PhoneAccountHandle, VisualVoicemailSmsFilterSettings) is received.

abstract void onStopped(VisualVoicemailService.VisualVoicemailTask task)

Called before the system is about to terminate a task.

static final void sendVisualVoicemailSms(Context context, PhoneAccountHandle phoneAccountHandle, String number, short port, String text, PendingIntent sentIntent)

Send a visual voicemail SMS.

static final void setSmsFilterSettings(Context context, PhoneAccountHandle phoneAccountHandle, VisualVoicemailSmsFilterSettings settings)

Set the visual voicemail SMS filter settings for the VisualVoicemailService.

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

SERVICE_INTERFACE

String SERVICE_INTERFACE

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

Constant Value: "android.telephony.VisualVoicemailService"

Public constructors

VisualVoicemailService

VisualVoicemailService ()

Public methods

onBind

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.

onCellServiceConnected

void onCellServiceConnected (VisualVoicemailService.VisualVoicemailTask task, 
                PhoneAccountHandle phoneAccountHandle)

Called when the cellular service is connected on a PhoneAccountHandle for the first time, or when the carrier config has changed. It will not be called when the signal is lost then restored.

Parameters
task VisualVoicemailService.VisualVoicemailTask: The task representing this event. finish() must be called when the task is completed.
phoneAccountHandle PhoneAccountHandle: The PhoneAccountHandle triggering this event.

onSimRemoved

void onSimRemoved (VisualVoicemailService.VisualVoicemailTask task, 
                PhoneAccountHandle phoneAccountHandle)

Called when a SIM is removed.

Parameters
task VisualVoicemailService.VisualVoicemailTask: The task representing this event. finish() must be called when the task is completed.
phoneAccountHandle PhoneAccountHandle: The PhoneAccountHandle triggering this event.

onSmsReceived

void onSmsReceived (VisualVoicemailService.VisualVoicemailTask task, 
                VisualVoicemailSms sms)

Called when a SMS matching the VisualVoicemailSmsFilterSettings set by setSmsFilterSettings(Context, PhoneAccountHandle, VisualVoicemailSmsFilterSettings) is received.

Parameters
task VisualVoicemailService.VisualVoicemailTask: The task representing this event. finish() must be called when the task is completed.
sms VisualVoicemailSms: The content of the received SMS.

onStopped

void onStopped (VisualVoicemailService.VisualVoicemailTask task)

Called before the system is about to terminate a task. The service should persist any necessary data and call finish on the task immediately.

Parameters
task VisualVoicemailService.VisualVoicemailTask

sendVisualVoicemailSms

void sendVisualVoicemailSms (Context context, 
                PhoneAccountHandle phoneAccountHandle, 
                String number, 
                short port, 
                String text, 
                PendingIntent sentIntent)

Send a visual voicemail SMS. The caller must be the current default dialer.

Requires Permission: SEND_SMS

Parameters
context Context
phoneAccountHandle PhoneAccountHandle: The account to send the SMS with.
number String: The destination number.
port short: The destination port for data SMS, or 0 for text SMS.
text String: The message content. For data sms, it will be encoded as a UTF-8 byte stream.
sentIntent PendingIntent: The sent intent passed to the SmsManager
Throws
SecurityException if the caller is not the current default dialer

See also:

setSmsFilterSettings

void setSmsFilterSettings (Context context, 
                PhoneAccountHandle phoneAccountHandle, 
                VisualVoicemailSmsFilterSettings settings)

Set the visual voicemail SMS filter settings for the VisualVoicemailService. onSmsReceived(VisualVoicemailTask, VisualVoicemailSms) will be called when a SMS matching the settings is received. The caller should have READ_PHONE_STATE and implements a VisualVoicemailService.

Requires Permission: READ_PHONE_STATE

Parameters
context Context
phoneAccountHandle PhoneAccountHandle: The account to apply the settings to.
settings VisualVoicemailSmsFilterSettings: The settings for the filter, or null to disable the filter.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.