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

# ModelDownloadListener

*** ** * ** ***

` public interface ModelDownloadListener `   
` `

|---|
| android.speech.ModelDownloadListener |

<br />

*** ** * ** ***

Listener for model download events. It makes `https://developer.android.com/reference/android/speech/RecognitionService` let callers know about the progress of model download for a single recognition request.

## Summary

| ### Public methods ||
|---|---|
| ` abstract void` | ` https://developer.android.com/reference/android/speech/ModelDownloadListener#onError(int)(int error) ` A network or scheduling error occurred. |
| ` abstract void` | ` https://developer.android.com/reference/android/speech/ModelDownloadListener#onProgress(int)(int completedPercent) ` Called by `https://developer.android.com/reference/android/speech/RecognitionService` only if the download has started after the request. |
| ` abstract void` | ` https://developer.android.com/reference/android/speech/ModelDownloadListener#onScheduled()() ` Called when `https://developer.android.com/reference/android/speech/RecognitionService` scheduled the download, but won't satisfy it immediately. |
| ` abstract void` | ` https://developer.android.com/reference/android/speech/ModelDownloadListener#onSuccess()() ` This method is called: - if the model is already available; - if the `https://developer.android.com/reference/android/speech/RecognitionService` has started and completed the download. <br /> |

## Public methods

### onError

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

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

A network or scheduling error occurred.

<br />

| Parameters ||
|---|---|
| `error` | `int`: code is defined in `https://developer.android.com/reference/android/speech/SpeechRecognizer` 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` |

### onProgress

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

```
public abstract void onProgress (int completedPercent)
```

Called by `https://developer.android.com/reference/android/speech/RecognitionService` only if the download has started after the request.

The number of calls to this method varies depending of the `https://developer.android.com/reference/android/speech/RecognitionService` implementation. If the download finished quickly enough, `https://developer.android.com/reference/android/speech/ModelDownloadListener#onSuccess()` may be called directly. In other cases, this method may be called any number of times during the download.

<br />

| Parameters ||
|---|---|
| `completedPercent` | `int`: the percentage of download that is completed <br /> |

### onScheduled

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

```
public abstract void onScheduled ()
```

Called when `https://developer.android.com/reference/android/speech/RecognitionService` scheduled the download, but won't satisfy it immediately. There will be no further updates on this listener.

<br />

### onSuccess

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

```
public abstract void onSuccess ()
```

This method is called:
- if the model is already available;
- if the `https://developer.android.com/reference/android/speech/RecognitionService` has started and completed the download.

  Once this method is called, the model can be safely used to satisfy recognition requests.

  <br />