Join us on the livestream at Android Dev Summit on 7-8 November 2018, starting at 10AM PDT!

Create input method editors on Wear

Wear OS by Google adds support for input methods beyond voice by extending the Android input method editor (IME) framework. The IME framework provides support for virtual, on-screen keyboards that allow users to input texts in the form of keyclicks, handwriting or gestures.

Wear users can choose between various input options from Remote Input. These options include:

  • Dictation
  • Emoji
  • Canned responses
  • Smart Reply
  • Default IME

Figure 1. Sample input methods

Wear comes with the system default Input Method Editor (IME) and opens up the IME APIs for third-party developers to create custom IMEs for Wear. The IME APIs used for Wear devices are the same as other form factors, though usage is slightly different due to limited screen real estate.

This document provides guidance that can help you create a Wear-specific IME

Create an input method for Wear

The Android platform provides a standard framework for creating IMEs. To create a Wear-specific IME, you need to optimize your IME for limited screen size.

To learn how to create an input method for wear, follow the guide to Creating an Input Method on handsets and add the following Google Play filters in your manifest file to make it a Wear-specific IME.

Wear-specific IME filters

  • API level

    If you are developing an IME for Wear, remember that the feature is supported only on Android 6.0 (API level 23) and higher versions of the platform. To ensure that your IME can only be installed on wearables that support input methods beyond voice, add the following to your app's manifest:

    <uses-sdk android:minSdkVersion="23" />
    

    This indicates that your app requires Android 6.0 or higher. For more information, see API Levels and the documentation for the <uses-sdk> element.

  • Device feature sets

    To control how your app is filtered from devices that do not support Wear IMEs (for example, on Phone), add the following to your app's manifest:

    <uses-feature android:required="true" android:name="android.hardware.type.watch" />
    

Invoke an input method

Wear provides user settings on the watch that lets the user to enable multiple IMEs from the list of installed IMEs. Once the users enable your IME, they can invoke your IME from:

  • A notification or an app using the RemoteInput API.
  • Wear apps with an EditText field. Touching a text field places the cursor in the field and automatically displays the IME on focus.

General IME considerations

Here are some things to consider when implementing IME for Wear:

  • Set default action

    RemoteInput and Wear apps expect only single-line text entry. The ENTER key should always trigger a call to sendDefaultEditorAction, which causes the app to dismiss the keyboard and continue on to the next step or action.

  • Use full-screen-mode IME

    Input methods on Wear consume most of the screen, leaving very little of the app visible; using full-screen mode ensures an optimal user experience regardless of the app UI. In full-screen mode, an ExtractEditText provides a mirrored view of the text field being edited and can be styled to blend with the rest of the input method UI. For more details on full-screen mode, see InputMethodService.

  • Handle InputType flags

    For privacy reasons, at a minimum you should handle the InputType flag TYPE_TEXT_VARIATION_PASSWORD in your IME. When your IME is in password mode, make sure that your keyboard is optimized for single key press (auto spelling correction, auto completion and gesture input are disabled). Most importantly, keyboard in password mode should support ASCII symbols regardless of the input language. For more details, see Specifying The Input Method Type.

  • Provide a key for switching to the next input method

    Android allows users to easily switch between all IMEs supported by the platform. In your IME implementation, set the boolean supportsSwitchingToNextInputMethod = true to enable your IME to support the switching mechanism (so that apps can switch to the next platform-supported IME). To learn more about how to implement switching between IMEs, see Switching among IME Subtypes.