Hi,
I am trying to implement a small soft keyboard which should simulate
HW key events. There should be an Up-Key, a Down-Key and an OK and
Cancel Button.
I made my own InputMethodService which is also defined in the Manifest
file:
<service android:name="MyInputMethod"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
<meta-data android:name="android.view.im"
android:resource="@xml/method" />>
</service>
Inside the service I want to send a KeyEvent to the current Activity.
Referring to the Developer Guide I can do this with the following
Code:
InputConnection ic = getCurrentInputConnection();
long eventTime = SystemClock.uptimeMillis();
ic.sendKeyEvent(new KeyEvent(eventTime, eventTime,
KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_UP, 0, 0, 0, 0,
KeyEvent.FLAG_SOFT_KEYBOARD|KeyEvent.FLAG_KEEP_TOUCH_MODE));
The Problem here: the InputConnection is null. I tried to manually
bind the Service to the activity, start the service, add the Service
as Inputmethod to an edittext but nothing seems to work. The
InputMethodService does not start in the right LifeCycle.
What am I missing? Any help here?
Thanks,
Michael
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en