I implement the RemoteInput input method by simply extending the InputMethodService, without InputViews and without a keyboard. When the user selects RemoteInput as the default IME, RemoteInput sends the current input status to another device, and the user can remotely perform input actions (using our client protocol). When the input is complete, the text entered into another device will be sent back to the current device, and then RemoteInput will transfer the text to the current user interface component (e.g. EditText) using InputConnection.commitText (CharSequence text, int newCursorPosition) .
It works great when text with remote input is English characters and numbers, but when it comes to other characters, things go wrong. I found that InputConnection.commitText filters other characters. For example, I entered helloไฝ ๅฅฝ , successfully completed only hello . And further:
hello world ==> helloworldhello,world!! ==> helloworld
Everything that you tell about this will be useful, thanks in advance.
Here is my code:
public class RemoteInput extends InputMethodService { protected static String TAG = "RemoteInput"; public static final String ACTION_INPUT_REQUEST = "com.aidufei.remoteInput.inputRequest"; public static final String ACTION_INPUT_DONE = "com.aidufei.remoteInput.inputDone"; private BroadcastReceiver mInputReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (ACTION_INPUT_DONE.equals(intent.getAction())) { String text = intent.getStringExtra("text"); Log.d(TAG, "broadcast ACTION_INPUT_DONE, input text: " + text); input(text); } } }; @Override public void onCreate() { super.onCreate(); registerReceiver(mInputReceiver, new IntentFilter(ACTION_INPUT_DONE)); } @Override public View onCreateInputView() {
source share