Stay organized with collections
Save and categorize content based on your preferences.
ModelDownloadListener
public
interface
ModelDownloadListener
android.speech.ModelDownloadListener
|
Listener for model download events. It makes RecognitionService
let callers know about
the progress of model download for a single recognition request.
Summary
Public methods |
abstract
void
|
onError(int error)
A network or scheduling error occurred.
|
abstract
void
|
onProgress(int completedPercent)
Called by RecognitionService only if the download has started after the request.
|
abstract
void
|
onScheduled()
Called when RecognitionService scheduled the download, but won't satisfy it
immediately.
|
abstract
void
|
onSuccess()
This method is called:
if the model is already available;
if the RecognitionService has started and completed the download.
|
Public methods
onError
public abstract void onError (int error)
A network or scheduling error occurred.
Parameters |
error |
int : code is defined in SpeechRecognizer
Value is SpeechRecognizer.ERROR_NETWORK_TIMEOUT , SpeechRecognizer.ERROR_NETWORK , SpeechRecognizer.ERROR_AUDIO , SpeechRecognizer.ERROR_SERVER , SpeechRecognizer.ERROR_CLIENT , SpeechRecognizer.ERROR_SPEECH_TIMEOUT , SpeechRecognizer.ERROR_NO_MATCH , SpeechRecognizer.ERROR_RECOGNIZER_BUSY , SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS , SpeechRecognizer.ERROR_TOO_MANY_REQUESTS , SpeechRecognizer.ERROR_SERVER_DISCONNECTED , SpeechRecognizer.ERROR_LANGUAGE_NOT_SUPPORTED , SpeechRecognizer.ERROR_LANGUAGE_UNAVAILABLE , SpeechRecognizer.ERROR_CANNOT_CHECK_SUPPORT , or SpeechRecognizer.ERROR_CANNOT_LISTEN_TO_DOWNLOAD_EVENTS |
onProgress
public abstract void onProgress (int completedPercent)
Called by RecognitionService
only if the download has started after the request.
The number of calls to this method varies depending of the RecognitionService
implementation. If the download finished quickly enough, onSuccess()
may be called
directly. In other cases, this method may be called any number of times during the download.
Parameters |
completedPercent |
int : the percentage of download that is completed |
onScheduled
public abstract void onScheduled ()
Called when RecognitionService
scheduled the download, but won't satisfy it
immediately. There will be no further updates on this listener.
onSuccess
public abstract void onSuccess ()
This method is called:
if the model is already available;
if the RecognitionService
has started and completed the download.
Once this method is called, the model can be safely used to satisfy recognition requests.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# ModelDownloadListener\n\nAdded in [API level 34](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nModelDownloadListener\n=====================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/speech/ModelDownloadListener \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\n\n\ninterface\nModelDownloadListener\n`\n\n\n`\n\n\n`\n\n|--------------------------------------|\n| android.speech.ModelDownloadListener |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nListener for model download events. It makes [RecognitionService](/reference/android/speech/RecognitionService) let callers know about\nthe progress of model download for a single recognition request.\n\nSummary\n-------\n\n| ### Public methods ||\n|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract void` | ` `[onError](/reference/android/speech/ModelDownloadListener#onError(int))`(int error) ` A network or scheduling error occurred. |\n| ` abstract void` | ` `[onProgress](/reference/android/speech/ModelDownloadListener#onProgress(int))`(int completedPercent) ` Called by [RecognitionService](/reference/android/speech/RecognitionService) only if the download has started after the request. |\n| ` abstract void` | ` `[onScheduled](/reference/android/speech/ModelDownloadListener#onScheduled())`() ` Called when [RecognitionService](/reference/android/speech/RecognitionService) scheduled the download, but won't satisfy it immediately. |\n| ` abstract void` | ` `[onSuccess](/reference/android/speech/ModelDownloadListener#onSuccess())`() ` This method is called: - if the model is already available; - if the [RecognitionService](/reference/android/speech/RecognitionService) has started and completed the download. \u003cbr /\u003e |\n\nPublic methods\n--------------\n\n### onError\n\nAdded in [API level 34](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void onError (int error)\n```\n\nA network or scheduling error occurred.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `error` | `int`: code is defined in [SpeechRecognizer](/reference/android/speech/SpeechRecognizer) Value is [SpeechRecognizer.ERROR_NETWORK_TIMEOUT](/reference/android/speech/SpeechRecognizer#ERROR_NETWORK_TIMEOUT), [SpeechRecognizer.ERROR_NETWORK](/reference/android/speech/SpeechRecognizer#ERROR_NETWORK), [SpeechRecognizer.ERROR_AUDIO](/reference/android/speech/SpeechRecognizer#ERROR_AUDIO), [SpeechRecognizer.ERROR_SERVER](/reference/android/speech/SpeechRecognizer#ERROR_SERVER), [SpeechRecognizer.ERROR_CLIENT](/reference/android/speech/SpeechRecognizer#ERROR_CLIENT), [SpeechRecognizer.ERROR_SPEECH_TIMEOUT](/reference/android/speech/SpeechRecognizer#ERROR_SPEECH_TIMEOUT), [SpeechRecognizer.ERROR_NO_MATCH](/reference/android/speech/SpeechRecognizer#ERROR_NO_MATCH), [SpeechRecognizer.ERROR_RECOGNIZER_BUSY](/reference/android/speech/SpeechRecognizer#ERROR_RECOGNIZER_BUSY), [SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS](/reference/android/speech/SpeechRecognizer#ERROR_INSUFFICIENT_PERMISSIONS), [SpeechRecognizer.ERROR_TOO_MANY_REQUESTS](/reference/android/speech/SpeechRecognizer#ERROR_TOO_MANY_REQUESTS), [SpeechRecognizer.ERROR_SERVER_DISCONNECTED](/reference/android/speech/SpeechRecognizer#ERROR_SERVER_DISCONNECTED), [SpeechRecognizer.ERROR_LANGUAGE_NOT_SUPPORTED](/reference/android/speech/SpeechRecognizer#ERROR_LANGUAGE_NOT_SUPPORTED), [SpeechRecognizer.ERROR_LANGUAGE_UNAVAILABLE](/reference/android/speech/SpeechRecognizer#ERROR_LANGUAGE_UNAVAILABLE), [SpeechRecognizer.ERROR_CANNOT_CHECK_SUPPORT](/reference/android/speech/SpeechRecognizer#ERROR_CANNOT_CHECK_SUPPORT), or [SpeechRecognizer.ERROR_CANNOT_LISTEN_TO_DOWNLOAD_EVENTS](/reference/android/speech/SpeechRecognizer#ERROR_CANNOT_LISTEN_TO_DOWNLOAD_EVENTS) \u003cbr /\u003e |\n\n### onProgress\n\nAdded in [API level 34](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void onProgress (int completedPercent)\n```\n\nCalled by [RecognitionService](/reference/android/speech/RecognitionService) only if the download has started after the request.\n\nThe number of calls to this method varies depending of the [RecognitionService](/reference/android/speech/RecognitionService)\nimplementation. If the download finished quickly enough, [onSuccess()](/reference/android/speech/ModelDownloadListener#onSuccess()) may be called\ndirectly. In other cases, this method may be called any number of times during the download.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------------------|------------------------------------------------------------|\n| `completedPercent` | `int`: the percentage of download that is completed \u003cbr /\u003e |\n\n### onScheduled\n\nAdded in [API level 34](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void onScheduled ()\n```\n\nCalled when [RecognitionService](/reference/android/speech/RecognitionService) scheduled the download, but won't satisfy it\nimmediately. There will be no further updates on this listener.\n\n\u003cbr /\u003e\n\n### onSuccess\n\nAdded in [API level 34](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void onSuccess ()\n```\n\nThis method is called:\n- if the model is already available;\n- if the [RecognitionService](/reference/android/speech/RecognitionService) has started and completed the download.\n\n Once this method is called, the model can be safely used to satisfy recognition requests.\n\n \u003cbr /\u003e"]]