0

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.

Winston
  • 38
  • 6
  • You have not indicated what happens when `startActivity` is called (or whether it is called at all). If it is called and nothing happens, I suggest using a logcat viewer to check for log messages that might indicate what is failing – Dave Nottage Dec 05 '22 at 18:48
  • I suspect you have not added `Androidapi.JNI.Speech` to your uses clause. You need this unit to use `RecognizerIntent` constants. – Alex Sawers Dec 06 '22 at 13:57
  • Thanks - I found this answer and it got me happy. - - - - https://fire-monkey.ru/topic/5863-%D1%80%D0%B0%D1%81%D0%BF%D0%BE%D0%B7%D0%BD%D0%B0%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5-%D1%80%D0%B5%D1%87%D0%B8/ - - - - I hope this helps someone else; – Winston Dec 08 '22 at 15:46

0 Answers0