InputMethodManager.SetExplicitlyEnabledInputMethodSubtypes Method

Definition

Updates the list of explicitly enabled InputMethodSubtype for a given IME owned by the calling process.

[Android.Runtime.Register("setExplicitlyEnabledInputMethodSubtypes", "(Ljava/lang/String;[I)V", "", ApiSince=34)]
public void SetExplicitlyEnabledInputMethodSubtypes (string imiId, int[] subtypeHashCodes);
[<Android.Runtime.Register("setExplicitlyEnabledInputMethodSubtypes", "(Ljava/lang/String;[I)V", "", ApiSince=34)>]
member this.SetExplicitlyEnabledInputMethodSubtypes : string * int[] -> unit

Parameters

imiId
String

IME ID. The specified IME and the calling process need to belong to the same package. Otherwise SecurityException will be thrown.

subtypeHashCodes
Int32[]

An arrays of InputMethodSubtype#hashCode() to be explicitly enabled. Entries that are found in the specified IME will be silently ignored. Pass an empty array to reset the state to default.

Attributes

Remarks

Updates the list of explicitly enabled InputMethodSubtype for a given IME owned by the calling process.

By default each IME has no explicitly enabled InputMethodSubtype. In this state the system will decide what InputMethodSubtype should be enabled by using information available at runtime as per-user language settings. Users can, however, manually pick up one or more InputMethodSubtype to be enabled on an Activity shown by #showInputMethodAndSubtypeEnabler(String). Such a manual change is stored in Settings.Secure#ENABLED_INPUT_METHODS so that the change can persist across reboots. Settings.Secure#ENABLED_INPUT_METHODS stores InputMethodSubtype#hashCode() as the identifier of InputMethodSubtype for historical reasons.

This API provides a safe and managed way for IME developers to modify what InputMethodSubtype are referenced in Settings.Secure#ENABLED_INPUT_METHODS for their own IME. One use case is when IME developers want to use their own Activity for users to pick up InputMethodSubtype. Another use case is for IME developers to fix up any stale and/or invalid value stored in Settings.Secure#ENABLED_INPUT_METHODS without bothering users. Passing an empty subtypeHashCodes is guaranteed to reset the state to default.

<h3>To control the return value of InputMethodSubtype#hashCode()</h3>

android.R.attr#subtypeId and android.view.inputmethod.InputMethodSubtype.InputMethodSubtypeBuilder#setSubtypeId(int) are available for IME developers to control the return value of InputMethodSubtype#hashCode(). Beware that -1 is not a valid value of InputMethodSubtype#hashCode() for historical reasons.

<h3>Note for Direct Boot support</h3>

While IME developers can call this API even before android.os.UserManager#isUserUnlocked() becomes true, such a change is volatile thus remains effective only until android.os.UserManager#isUserUnlocked() becomes true or the device is rebooted. To make the change persistent IME developers need to call this API again after receiving Intent#ACTION_USER_UNLOCKED.

Java documentation for android.view.inputmethod.InputMethodManager.setExplicitlyEnabledInputMethodSubtypes(java.lang.String, int[]).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to