Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

# RecognitionListener

*** ** * ** ***


`
public


interface
RecognitionListener
`


`


`

|---|
| android.speech.RecognitionListener |

<br />

*** ** * ** ***

Used for receiving notifications from the SpeechRecognizer when the
recognition related events occur. All the callbacks are executed on the
Application main thread.

## Summary

| ### Public methods ||
|---|---|
| ` abstract void` | ` https://developer.android.com/reference/android/speech/RecognitionListener#onBeginningOfSpeech()() ` The user has started to speak. |
| ` abstract void` | ` https://developer.android.com/reference/android/speech/RecognitionListener#onBufferReceived(byte[])(byte[] buffer) ` More sound has been received. |
| ` default void` | ` https://developer.android.com/reference/android/speech/RecognitionListener#onEndOfSegmentedSession()() ` Called at the end of a segmented recognition request. |
| ` abstract void` | ` https://developer.android.com/reference/android/speech/RecognitionListener#onEndOfSpeech()() ` Called after the user stops speaking. |
| ` abstract void` | ` https://developer.android.com/reference/android/speech/RecognitionListener#onError(int)(int error) ` A network or recognition error occurred. |
| ` abstract void` | ` https://developer.android.com/reference/android/speech/RecognitionListener#onEvent(int,%20android.os.Bundle)(int eventType, https://developer.android.com/reference/android/os/Bundle params) ` Reserved for adding future events. |
| ` default void` | ` https://developer.android.com/reference/android/speech/RecognitionListener#onLanguageDetection(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle results) ` Called when the language detection (and switching) results are available. |
| ` abstract void` | ` https://developer.android.com/reference/android/speech/RecognitionListener#onPartialResults(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle partialResults) ` Called when partial recognition results are available. |
| ` abstract void` | ` https://developer.android.com/reference/android/speech/RecognitionListener#onReadyForSpeech(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle params) ` Called when the endpointer is ready for the user to start speaking. |
| ` abstract void` | ` https://developer.android.com/reference/android/speech/RecognitionListener#onResults(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle results) ` Called when recognition results are ready. |
| ` abstract void` | ` https://developer.android.com/reference/android/speech/RecognitionListener#onRmsChanged(float)(float rmsdB) ` The sound level in the audio stream has changed. |
| ` default void` | ` https://developer.android.com/reference/android/speech/RecognitionListener#onSegmentResults(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle segmentResults) ` Called for each ready segment of a recognition request. |

## Public methods

### onBeginningOfSpeech

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void onBeginningOfSpeech ()
```

The user has started to speak.

<br />

### onBufferReceived

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void onBufferReceived (byte[] buffer)
```

More sound has been received. The purpose of this function is to allow giving feedback to the
user regarding the captured audio. There is no guarantee that this method will be called.

<br />

| Parameters ||
|---|---|
| `buffer` | `byte`: a buffer containing a sequence of big-endian 16-bit integers representing a single channel audio stream. The sample rate is implementation dependent. <br /> |

### onEndOfSegmentedSession

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onEndOfSegmentedSession ()
```

Called at the end of a segmented recognition request. To request segmented speech results
use `https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_SEGMENTED_SESSION`.

<br />

### onEndOfSpeech

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void onEndOfSpeech ()
```

Called after the user stops speaking.

<br />

### onError

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void onError (int error)
```

A network or recognition error occurred.

<br />

| Parameters ||
|---|---|
| `error` | `int`: code is defined in `https://developer.android.com/reference/android/speech/SpeechRecognizer`. Implementations need to handle any integer error constant to be passed here beyond constants prefixed with ERROR_. Value is one of the following: - `https://developer.android.com/reference/android/speech/SpeechRecognizer#ERROR_NETWORK_TIMEOUT` - `https://developer.android.com/reference/android/speech/SpeechRecognizer#ERROR_NETWORK` - `https://developer.android.com/reference/android/speech/SpeechRecognizer#ERROR_AUDIO` - `https://developer.android.com/reference/android/speech/SpeechRecognizer#ERROR_SERVER` - `https://developer.android.com/reference/android/speech/SpeechRecognizer#ERROR_CLIENT` - `https://developer.android.com/reference/android/speech/SpeechRecognizer#ERROR_SPEECH_TIMEOUT` - `https://developer.android.com/reference/android/speech/SpeechRecognizer#ERROR_NO_MATCH` - `https://developer.android.com/reference/android/speech/SpeechRecognizer#ERROR_RECOGNIZER_BUSY` - `https://developer.android.com/reference/android/speech/SpeechRecognizer#ERROR_INSUFFICIENT_PERMISSIONS` - `https://developer.android.com/reference/android/speech/SpeechRecognizer#ERROR_TOO_MANY_REQUESTS` - `https://developer.android.com/reference/android/speech/SpeechRecognizer#ERROR_SERVER_DISCONNECTED` - `https://developer.android.com/reference/android/speech/SpeechRecognizer#ERROR_LANGUAGE_NOT_SUPPORTED` - `https://developer.android.com/reference/android/speech/SpeechRecognizer#ERROR_LANGUAGE_UNAVAILABLE` - `https://developer.android.com/reference/android/speech/SpeechRecognizer#ERROR_CANNOT_CHECK_SUPPORT` - `https://developer.android.com/reference/android/speech/SpeechRecognizer#ERROR_CANNOT_LISTEN_TO_DOWNLOAD_EVENTS` |

### onEvent

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void onEvent (int eventType, 
                Bundle params)
```

Reserved for adding future events.

<br />

| Parameters ||
|---|---|
| `eventType` | `int`: the type of the occurred event <br /> |
| `params` | `Bundle`: a Bundle containing the passed parameters <br /> |

### onLanguageDetection

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onLanguageDetection (Bundle results)
```

Called when the language detection (and switching) results are available. This callback
can be invoked on any number of occasions at any time between `https://developer.android.com/reference/android/speech/RecognitionListener#onBeginningOfSpeech()`
and `https://developer.android.com/reference/android/speech/RecognitionListener#onEndOfSpeech()`, depending on the speech recognition service implementation.

To request language detection,
use `https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_ENABLE_LANGUAGE_DETECTION`.

To request automatic language switching,
use `https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_ENABLE_LANGUAGE_SWITCH`.

<br />

| Parameters ||
|---|---|
| `results` | `Bundle`: the returned language detection (and switching) results. To retrieve the most confidently detected language IETF tag (as defined by BCP 47, e.g., "en-US", "de-DE"), use `https://developer.android.com/reference/android/os/BaseBundle#getString(java.lang.String)` with `https://developer.android.com/reference/android/speech/SpeechRecognizer#DETECTED_LANGUAGE` as the parameter. To retrieve the language detection confidence level represented by a value prefixed by `LANGUAGE_DETECTION_CONFIDENCE_LEVEL_` and defined in `https://developer.android.com/reference/android/speech/SpeechRecognizer`, use `https://developer.android.com/reference/android/os/BaseBundle#getInt(java.lang.String)` with `https://developer.android.com/reference/android/speech/SpeechRecognizer#LANGUAGE_DETECTION_CONFIDENCE_LEVEL` as the parameter. To retrieve the alternative locales for the same language retrieved by the key `https://developer.android.com/reference/android/speech/SpeechRecognizer#DETECTED_LANGUAGE`, use `https://developer.android.com/reference/android/os/Bundle#getStringArrayList(java.lang.String)` with `https://developer.android.com/reference/android/speech/SpeechRecognizer#TOP_LOCALE_ALTERNATIVES` as the parameter. To retrieve the language switching results represented by a value prefixed by `LANGUAGE_SWITCH_RESULT_` and defined in `https://developer.android.com/reference/android/speech/SpeechRecognizer`, use `https://developer.android.com/reference/android/os/BaseBundle#getInt(java.lang.String)` with `https://developer.android.com/reference/android/speech/SpeechRecognizer#LANGUAGE_SWITCH_RESULT` as the parameter. This value cannot be `null`. |

### onPartialResults

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void onPartialResults (Bundle partialResults)
```

Called when partial recognition results are available. The callback might be called at any
time between `https://developer.android.com/reference/android/speech/RecognitionListener#onBeginningOfSpeech()` and `https://developer.android.com/reference/android/speech/RecognitionListener#onResults(android.os.Bundle)` when partial
results are ready. This method may be called zero, one or multiple times for each call to
`https://developer.android.com/reference/android/speech/SpeechRecognizer#startListening(android.content.Intent)`, depending on the speech recognition
service implementation. To request partial results, use
`https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_PARTIAL_RESULTS`

<br />

| Parameters ||
|---|---|
| `partialResults` | `Bundle`: the returned results. To retrieve the results in ArrayList\<String\> format use `https://developer.android.com/reference/android/os/Bundle#getStringArrayList(java.lang.String)` with `https://developer.android.com/reference/android/speech/SpeechRecognizer#RESULTS_RECOGNITION` as a parameter <br /> |

### onReadyForSpeech

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void onReadyForSpeech (Bundle params)
```

Called when the endpointer is ready for the user to start speaking.

<br />

| Parameters ||
|---|---|
| `params` | `Bundle`: parameters set by the recognition service. Reserved for future use. <br /> |

### onResults

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void onResults (Bundle results)
```

Called when recognition results are ready.


Called with the results for the full speech since `https://developer.android.com/reference/android/speech/RecognitionListener#onReadyForSpeech(android.os.Bundle)`.
To get recognition results in segments rather than for the full session see
`https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_SEGMENTED_SESSION`.

<br />

<br />

| Parameters ||
|---|---|
| `results` | `Bundle`: the recognition results. To retrieve the results in `ArrayList<String>` format use `https://developer.android.com/reference/android/os/Bundle#getStringArrayList(java.lang.String)` with `https://developer.android.com/reference/android/speech/SpeechRecognizer#RESULTS_RECOGNITION` as a parameter. A float array of confidence values might also be given in `https://developer.android.com/reference/android/speech/SpeechRecognizer#CONFIDENCE_SCORES`. <br /> |

### onRmsChanged

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void onRmsChanged (float rmsdB)
```

The sound level in the audio stream has changed. There is no guarantee that this method will
be called.

<br />

| Parameters ||
|---|---|
| `rmsdB` | `float`: the new RMS dB value <br /> |

### onSegmentResults

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onSegmentResults (Bundle segmentResults)
```

Called for each ready segment of a recognition request. To request segmented speech results
use `https://developer.android.com/reference/android/speech/RecognizerIntent#EXTRA_SEGMENTED_SESSION`. The callback might be called
any number of times between `https://developer.android.com/reference/android/speech/RecognitionListener#onReadyForSpeech(android.os.Bundle)` and
`https://developer.android.com/reference/android/speech/RecognitionListener#onEndOfSegmentedSession()`.

<br />

| Parameters ||
|---|---|
| `segmentResults` | `Bundle`: the returned results. To retrieve the results in ArrayList\<String\> format use `https://developer.android.com/reference/android/os/Bundle#getStringArrayList(java.lang.String)` with `https://developer.android.com/reference/android/speech/SpeechRecognizer#RESULTS_RECOGNITION` as a parameter. This value cannot be `null`. <br /> |