I'm wanting to send an ACTION_RECOGNIZE_SPEECH Intent using Delphi 10.4

114 views Asked by At

I can send intents and handle the actions etc but I have run nto a new problem regarding speech in Android.

The intent looks like this:

     procedure TsendForm.Button8Click(Sender: TObject);
      var
      Intent: JIntent;
     begin
      Intent := TJIntent.Create;
        // example : Intent.setAction(TJIntent.JavaClass.ACTION_OPEN_DOCUMENT);
        //--->>>  there is no TJIntent.JavaClass.? intent for ACTION_RECOGNIZE_SPEECH
   
       Intent.setAction(stringToJstring('ACTION_RECOGNIZE_SPEECH'));

       // I want this intent
      //stringtoJstring('RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM')
      Intent.putExtra(TJIntent.JavaClass.EXTRA_TEXT, StringToJString('EXTRA_LANGUAGE_MODEL,             LANGUAGE_MODEL_FREE_FORM'));

        if MainActivity.getPackageManager.queryIntentActivities(Intent,                     TJPackageManager.JavaClass.MATCH_DEFAULT_ONLY).size > 0 then
     MainActivity.startActivity(Intent)

         else
         ShowMessage('Receiver not found');

        // ive tried starting the intent with and without action
       // TAndroidHelper.Activity.startActivityForResult(Intent,ACTION_RECOGNIZE_SPEECH);
       // Intent.setAction('ACTION_RECOGNIZE_SPEECH');
end;

Does anyone know how to construct the intent. Any input will be appreciated. I'm sure there is a way to do this but I would like someone to steer me in the right direction.

0

There are 0 answers