Home | History | Annotate | Download | only in features
      1 page.title=Wear Input Method Framework
      2 meta.tags="wear", "wear-preview", "input-method", "ime"
      3 page.tags="wear"
      4 
      5 @jd:body
      6 
      7 
      8 <div id="qv-wrapper">
      9 <div id="qv">
     10 
     11     <h2>In this document</h2>
     12     <ol>
     13       <li><a href="#creating">Creating an Input Method for Wear</a></li>
     14       <li><a href="#invoking">Invoking IME</a></li>
     15       <li><a href="#considerations">General IME Considerations</a></li>
     16     </ol>
     17 
     18 </div>
     19 </div>
     20 
     21 
     22 <p>Wear 2.0 supports input methods beyond voice by extending the Android
     23 Input Method Framework (IMF) to Android Wear. IMF allows for virtual, on-screen
     24  keyboards and other input methods to be used for text entry. The IMF APIs used
     25  for Wear devices are the same as other form factors, though usage is slightly
     26  different due to limited screen real estate.</p>
     27 
     28 <p>Wear 2.0 comes with the system default Input Method Editor (IME)
     29 and opens up the IMF APIs for third-party developers to create custom input
     30 methods for Wear.</p>
     31 
     32 <p><img src="{@docRoot}wear/preview/images/new_input_methods.png"></p>
     33 <p><b>Figure 1</b>. Sample input methods </p>
     34 
     35 <h2 id="creating">Creating an Input Method for Wear</h2>
     36 <p>The Android platform provides a standard framework for creating IMEs. To create
     37  a Wear-specific IME, you need to optimize your IME for limited screen size.
     38   </p>
     39 
     40 <p>This document provides guidance that can help you create a Wear-specific IME.
     41 Before you continue with this guide, it's important that you read the
     42 documentation for
     43 <a href="{@docRoot}guide/topics/text/creating-input-method.html">Creating an Input Method</a>
     44  on handsets.
     45 </p>
     46 
     47 
     48 <h2 id="invoking">Invoking an Input Method</h2>
     49 If you are developing an IME for Wear, remember that the
     50 feature is supported only on Android 6.0 (API level 23) and higher versions of
     51 the platform.
     52 To ensure that your IME can only be installed on Wearables that support input
     53 methods beyond voice, add the following to your app's manifest:
     54 <pre>
     55 &lt;uses-sdk android:minSdkVersion="23" />
     56 </pre>
     57 This indicates that your app requires Android 6.0 or higher.
     58 For more information, see <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#ApiLevels">API Levels</a>
     59  and the documentation for the <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">&lt;uses-sdk></a>
     60 element.
     61 <p>
     62 To control how your app is filtered from devices that do not support Wear
     63 IMEs (for example, on Phone), add the following to your app's manifest:
     64 </p>
     65 <pre>
     66 &lt;uses-feature android:required="true" android:name="android.hardware.type.watch" />
     67 </pre>
     68 
     69 <p>Wear provides user settings on the watch that lets the user to enable multiple
     70  IMEs from the list of installed IMEs. Once the users enable your IME, they
     71  can invoke your IME from:</p>
     72 <ul>
     73 <li>A notification or an app using the
     74 <a href="{@docRoot}reference/android/support/v4/app/RemoteInput.html">RemoteInput</a></code> API.</li>
     75 <li>Wear apps with an
     76 <a href="{@docRoot}reference/android/widget/EditText.html">EditText</a>
     77  field. Touching a text field places the cursor in the field and automatically
     78  displays the IME on focus.</li>
     79 </ul>
     80 
     81 
     82 <h2 id="considerations">General IME Considerations</h2>
     83 
     84 <p>Here are some things to consider when implementing IME for Wear:</p>
     85 
     86 <ul>
     87 <li><strong>Set Default Action</strong>
     88 <p>
     89 <a href="http://developer.android.com/reference/android/support/v4/app/RemoteInput.html">{@code RemoteInput}</a>
     90 and Wear apps expect only single-line text entry. The ENTER key should always trigger
     91  a call to <a href="{@docRoot}reference/android/inputmethodservice/InputMethodService.html#sendDefaultEditorAction(boolean)">sendDefaultEditorAction</a>,
     92   which causes the app to dismiss the keyboard and continue on to the next step
     93   or action.</p>
     94 </li>
     95 
     96 <li><Strong>Use full-screen-mode IME</strong>
     97 <p>
     98 Input methods on Wear consume most of the screen, leaving very little of the
     99  app visible; using full-screen mode ensures an optimal user experience regardless
    100   of the app UI.  In full-screen mode, an
    101   <a href="{@docRoot}reference/android/view/inputmethod/ExtractedText.html">{@code ExtractEditText}</a> provides a mirrored
    102    view of the text field being edited and can be styled to blend with the rest of
    103     the input method UI. For more details on full-screen mode, see
    104     <a href="{@docRoot}reference/android/inputmethodservice/InputMethodService.html">InputMethodService</a>.
    105 </p>
    106 </li>
    107 
    108 <li><strong>Handle InputType flags</strong>
    109 <p>
    110 For privacy reasons, at a minimum you should handle the {@code InputType}
    111 flag {@code TYPE_TEXT_VARIATION_PASSWORD} in your IME. When your IME is in
    112 password mode, make sure that your keyboard is optimized for single key press
    113 (auto spelling correction, auto completion and gesture input are disabled).
    114 Most importantly, keyboard in password mode should support ASCII symbols
    115 regardless of the input language.  For more details, see
    116 <a href="{@docRoot}training/keyboard-input/style.html">Specifying The Input Method Type</a>.
    117 </p>
    118 </li>
    119 
    120 <li><strong>Provide a key for switching to the next input method</strong>
    121 <p>
    122 Android allows users to easily switch between all IMEs supported by the platform.
    123  In your IME implementation, set the boolean
    124  <a href="{@docRoot}guide/topics/text/creating-input-method.html#Switching">supportsSwitchingToNextInputMethod = true</a>
    125  to enable your IME to support the switching mechanism
    126  (so that apps can switch to the next platform-supported IME).
    127 </p>
    128 </li>
    129 </ul>
    130 
    131 
    132 
    133 
    134