Skip to content

Most visited

Recently visited

navigation

RecognitionService

public abstract class RecognitionService
extends Service

java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ android.speech.RecognitionService


This class provides a base class for recognition service implementations. This class should be extended only in case you wish to implement a new speech recognizer. Please note that the implementation of this service is stateless.

Summary

Nested classes

class RecognitionService.Callback

This class receives callbacks from the speech recognition service and forwards them to the user. 

Constants

String SERVICE_INTERFACE

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

String SERVICE_META_DATA

Name under which a RecognitionService component publishes information about itself.

Inherited constants

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

Public constructors

RecognitionService()

Public methods

final IBinder onBind(Intent intent)

Return the communication channel to the service.

void onDestroy()

Called by the system to notify a Service that it is no longer used and is being removed.

Protected methods

abstract void onCancel(RecognitionService.Callback listener)

Notifies the service that it should cancel the speech recognition.

abstract void onStartListening(Intent recognizerIntent, RecognitionService.Callback listener)

Notifies the service that it should start listening for speech.

abstract void onStopListening(RecognitionService.Callback listener)

Notifies the service that it should stop listening for speech.

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

Added in API level 8
String SERVICE_INTERFACE

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

Constant Value: "android.speech.RecognitionService"

SERVICE_META_DATA

Added in API level 8
String SERVICE_META_DATA

Name under which a RecognitionService component publishes information about itself. This meta-data should reference an XML resource containing a <recognition-service> tag.

Constant Value: "android.speech"

Public constructors

RecognitionService

Added in API level 8
RecognitionService ()

Public methods

onBind

Added in API level 8
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.

onDestroy

Added in API level 8
void onDestroy ()

Called by the system to notify a Service that it is no longer used and is being removed. The service should clean up any resources it holds (threads, registered receivers, etc) at this point. Upon return, there will be no more calls in to this Service object and it is effectively dead. Do not call this method directly.

Protected methods

onCancel

Added in API level 8
void onCancel (RecognitionService.Callback listener)

Notifies the service that it should cancel the speech recognition.

Parameters
listener RecognitionService.Callback

onStartListening

Added in API level 8
void onStartListening (Intent recognizerIntent, 
                RecognitionService.Callback listener)

Notifies the service that it should start listening for speech.

Parameters
recognizerIntent Intent: contains parameters for the recognition to be performed. The intent may also contain optional extras, see RecognizerIntent. If these values are not set explicitly, default values should be used by the recognizer.
listener RecognitionService.Callback: that will receive the service's callbacks

onStopListening

Added in API level 8
void onStopListening (RecognitionService.Callback listener)

Notifies the service that it should stop listening for speech. Speech captured so far should be recognized as if the user had stopped speaking at this point. This method is only called if the application calls it explicitly.

Parameters
listener RecognitionService.Callback
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.