Package org.robolectric.shadows
Class ShadowSpeechRecognizer
java.lang.Object
org.robolectric.shadows.ShadowSpeechRecognizer
- Direct Known Subclasses:
ShadowSpeechRecognizerImpl
,ShadowSpeechRecognizerProxy
@Implements(android.speech.SpeechRecognizer.class)
public class ShadowSpeechRecognizer
extends Object
Robolectric shadow for SpeechRecognizer.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static interface
An interface to access direct functions/variables of an instance ofSpeechRecognizer
.static class
The state of a specific instance ofShadowSpeechRecognizer
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
checkRecognitionSupport
(Intent recognizerIntent, Executor executor, Object supportListener) protected static SpeechRecognizer
createOnDeviceSpeechRecognizer
(Context context) protected static SpeechRecognizer
createSpeechRecognizer
(Context context, ComponentName serviceComponent) protected void
destroy()
Returns theShadowSpeechRecognizer.ShadowSpeechRecognizerDirectAccessors
implementation that can handle direct access to functions/variables of a realSpeechRecognizer
.Returns the argument passed to the last call toSpeechRecognizer.startListening(android.content.Intent)
.static SpeechRecognizer
Returns the latest SpeechRecognizer.getState()
Returns the state of this shadow instance.protected void
handleChangeListener
(RecognitionListener listener) Handles changing the listener and allows access to the internal listener to trigger events.boolean
Returns true iff the destroy method of was invoked for the recognizer.protected static boolean
isOnDeviceRecognitionAvailable
(Context context) static void
reset()
static void
setIsOnDeviceRecognitionAvailable
(boolean available) protected void
startListening
(Intent recognizerIntent) protected void
triggerModelDownload
(Intent recognizerIntent) void
void
triggerOnError
(int error) void
triggerOnPartialResults
(Bundle bundle) void
triggerOnReadyForSpeech
(Bundle bundle) void
triggerOnResults
(Bundle bundle) void
triggerOnRmsChanged
(float rmsdB) void
triggerSupportError
(int error) void
triggerSupportResult
(Object recognitionSupport)
-
Constructor Details
-
ShadowSpeechRecognizer
public ShadowSpeechRecognizer()
-
-
Method Details
-
reset
-
getLatestSpeechRecognizer
Returns the latest SpeechRecognizer. This method can only be called afterSpeechRecognizer.createSpeechRecognizer(Context)
is called. -
createSpeechRecognizer
@Implementation protected static SpeechRecognizer createSpeechRecognizer(Context context, ComponentName serviceComponent) -
createOnDeviceSpeechRecognizer
@Implementation(minSdk=33) protected static SpeechRecognizer createOnDeviceSpeechRecognizer(Context context) -
setIsOnDeviceRecognitionAvailable
public static void setIsOnDeviceRecognitionAvailable(boolean available) -
isOnDeviceRecognitionAvailable
-
getState
Returns the state of this shadow instance.Subclasses may override this function to customize which state is returned.
-
getDirectAccessors
Returns theShadowSpeechRecognizer.ShadowSpeechRecognizerDirectAccessors
implementation that can handle direct access to functions/variables of a realSpeechRecognizer
.Subclasses may override this function to customize access in case they are shadowing a subclass of
SpeechRecognizer
that functions differently than the parent class. -
isDestroyed
public boolean isDestroyed()Returns true iff the destroy method of was invoked for the recognizer. -
destroy
-
getLastRecognizerIntent
Returns the argument passed to the last call toSpeechRecognizer.startListening(android.content.Intent)
. -
startListening
-
handleChangeListener
@Implementation(maxSdk=34) @InDevelopment protected void handleChangeListener(RecognitionListener listener) Handles changing the listener and allows access to the internal listener to trigger events. -
triggerOnEndOfSpeech
public void triggerOnEndOfSpeech() -
triggerOnError
public void triggerOnError(int error) -
triggerOnReadyForSpeech
-
triggerOnPartialResults
-
triggerOnResults
-
triggerOnRmsChanged
public void triggerOnRmsChanged(float rmsdB) -
checkRecognitionSupport
@RequiresApi(api=33) @Implementation(minSdk=33, maxSdk=34) protected void checkRecognitionSupport(Intent recognizerIntent, Executor executor, Object supportListener) -
getLatestModelDownloadIntent
-
triggerModelDownload
-
triggerSupportResult
-
triggerSupportError
-