diTii.com Digital News Hub

Sign up with your email address to be the first to know about latest news and more.

I agree to have my personal information transfered to MailChimp (more information)


Integrate Voice Typing Feature to Android 4.0 IME Apps

A ‘Voice Typing’ feature in Android 4.0 makes it easy for users to do more with their Android devices, “the difference for users is that the recognition results appear in the text box while they are still speaking. If you are an IME developer, you can easily integrate with voice typing, we appreciate your support in adding it to your IMEs,” blogged Android Developer team.

“To simplify the integration, if you download this library and modify your IME as described below, everything will work smoothly on any device with Android 2.2 or later. On 4.0+, users will get voice typing, and earlier versions will use standard voice recognition; the difference is illustrated below,” informs the team.

To see how to integrate voice typing you can take a look at this sample IME. The IME is really simple and contains only one button: a microphone. By pressing the microphone, the user triggers voice recognition.

Android 4.0 is voice typing: Add Voice Typing To Your IME

Here are the steps that you need to follow to integrate voice recognition into your IME:

  1. “Download the library
    Download this library and add it to your IME APK.
    Create the voice recognition trigger: The library contains the VoiceRecognitionTrigger helper class. Create an instance of it inside the InputMethodService#onCreate method in your IME.
  2. Add the microphone icon to your IME: You need to modify the UI of your IME, add a microphone icon, and register an OnClickListener to trigger voice recognition. You can find the assets inside the sample IME. The microphone icon should be displayed only if voice recognition is installed; use VoiceRecognitionTrigger#isInstalled().

    If your IME supports multiple languages, you can specify in which language recognition should be done as a parameter of startVoiceRecognition().

  3. Notify the trigger when your IME starts: When your IME starts, you need to notify the trigger, so it can insert into the text view any pending recognition results.
  4. Modify your AndroidManifest: In order to start a voice recognition through the Intent API, the library uses a service and an activity, and you need to add them into your manifest.
  5. Update the microphone icon dynamically (optional): This step is optional, but you should implement it if possible as it will improve the user experience. Voice recognition requires network access, and if there is no network, your IME should notify the user that voice recognition is currently disabled. To achieve this, you need to register the VoiceRecognitionTrigger.Listener and enable/disable the microphone accordingly.

    The listener is registered in InputMethodService#onCreate, and you have to unregister it in InputMethodService#onDestroy, otherwise you will leak the listener.

  6. And add this permission into your manifest:
  7. That’s all there is to it!,” explained Adnroid Developer team.
    Share This Story, Choose Your Platform!

    Get Latest News

    Subscribe to Digital News Hub

    Get our daily newsletter about the latest news in the industry.
    First Name
    Last Name
    Email address
    Secure and Spam free...