Dela via


SpeechRecognizer.CreateSpeechRecognizer Method

Definition

Overloads

CreateSpeechRecognizer(Context)

Factory method to create a new SpeechRecognizer.

CreateSpeechRecognizer(Context, ComponentName)

Factory method to create a new SpeechRecognizer.

CreateSpeechRecognizer(Context)

Factory method to create a new SpeechRecognizer.

[Android.Runtime.Register("createSpeechRecognizer", "(Landroid/content/Context;)Landroid/speech/SpeechRecognizer;", "")]
public static Android.Speech.SpeechRecognizer? CreateSpeechRecognizer (Android.Content.Context? context);
[<Android.Runtime.Register("createSpeechRecognizer", "(Landroid/content/Context;)Landroid/speech/SpeechRecognizer;", "")>]
static member CreateSpeechRecognizer : Android.Content.Context -> Android.Speech.SpeechRecognizer

Parameters

context
Context

in which to create SpeechRecognizer

Returns

a new SpeechRecognizer

Attributes

Remarks

Factory method to create a new SpeechRecognizer. Please note that #setRecognitionListener(RecognitionListener) should be called before dispatching any command to the created SpeechRecognizer, otherwise no notifications will be received.

For apps targeting Android 11 (API level 30) interaction with a speech recognition service requires <queries> element to be added to the manifest file:

{@code
<queries>
<intent>
<action
                   android:name="android.speech.RecognitionService" />
</intent>
</queries>
            }

Java documentation for android.speech.SpeechRecognizer.createSpeechRecognizer(android.content.Context).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

CreateSpeechRecognizer(Context, ComponentName)

Factory method to create a new SpeechRecognizer.

[Android.Runtime.Register("createSpeechRecognizer", "(Landroid/content/Context;Landroid/content/ComponentName;)Landroid/speech/SpeechRecognizer;", "")]
public static Android.Speech.SpeechRecognizer? CreateSpeechRecognizer (Android.Content.Context? context, Android.Content.ComponentName? serviceComponent);
[<Android.Runtime.Register("createSpeechRecognizer", "(Landroid/content/Context;Landroid/content/ComponentName;)Landroid/speech/SpeechRecognizer;", "")>]
static member CreateSpeechRecognizer : Android.Content.Context * Android.Content.ComponentName -> Android.Speech.SpeechRecognizer

Parameters

context
Context

in which to create SpeechRecognizer

serviceComponent
ComponentName

the ComponentName of a specific service to direct this SpeechRecognizer to

Returns

a new SpeechRecognizer

Attributes

Remarks

Factory method to create a new SpeechRecognizer. Please note that #setRecognitionListener(RecognitionListener) should be called before dispatching any command to the created SpeechRecognizer, otherwise no notifications will be received. Use this version of the method to specify a specific service to direct this SpeechRecognizer to.

<strong>Important</strong>: before calling this method, please check via android.content.pm.PackageManager#queryIntentServices(Intent, int) that serviceComponent actually exists and provides RecognitionService#SERVICE_INTERFACE. Normally you would not use this; call #createSpeechRecognizer(Context) to use the system default recognition service instead or #createOnDeviceSpeechRecognizer(Context) to use on-device recognition.

For apps targeting Android 11 (API level 30) interaction with a speech recognition service requires <queries> element to be added to the manifest file:

{@code
<queries>
<intent>
<action
                   android:name="android.speech.RecognitionService" />
</intent>
</queries>
            }

Java documentation for android.speech.SpeechRecognizer.createSpeechRecognizer(android.content.Context, android.content.ComponentName).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to