Added in API level 34

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

    onProgress

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

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

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