My Android app features a text input box that has a button on the right of the EditText to call the voice-input feature.
I am porting the app with Codename One. At present time the iOS port is the goal.
The button has a suitable icon. This is the code:
voiceInputButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent voiceIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
try {
activity.startActivityForResult(voiceIntent, RESULT_SPEECH_REQUEST_CODE);
} catch (ActivityNotFoundException ex) {
}
}
});
It works very well, the voice-input screen is called and then the result is passed back to the app as a string.
The string is what the user said (for example, a single word).
I need to have this functionality in the CodenameOne app for iOS.
What should be the equivalent? Is it necessary to call native iOS functions, through the native interface?
ANY, for example in a code like:TextField myField = new TextField("", "myHint", 80, TextArea.ANY);, the iOS VKB (virtual keyboard) has in the bottom right an icon to dictate the text. It's not what you asked, but it's something available by default. Other constraints, like EMAIL, don't show the option to dictate text. I suppose you need a native interface to dictate text without opening the VKB, but I'm not sure. - Francesco Galgani.setOnClickListeneris.addActionListener. - Francesco Galgani