How to set selection of editText by using SendKeyEvent function of InputConnection class

by DrBrain » Thu, 30 Apr 2009 02:06:02 GMT

Sponsored Links
 I need to set selection of an editText box via InputConnection. I used
the SendKeyEvent function with the KEYCODE_DPAD_LEFT and META_SHIFT_ON
state but I've had no luck. My code is as below:

// I've already received hardware key event of DPAD left key as event
parameter in this function.

// Change the meta state of event parameter to META_SHIFT_ON
event = new KeyEvent(event.getDownTime(), event.getEventTime(),
                        event.getAction(), event.getKeyCode(), 
                        event.getDeviceId(), event.getScanCode());
InputConnection ic = getCurrentInputConnection();

After excuting the code, there still no selection in the EditText.

Could somebody help me to resolve this ?

Thanks in advance.


Other Threads

1. Exchange Client

Dear para Suhu,

Push email exchange pake apa ya?

tx a lot

Google Groups "Indonesian Android Community [id-android]" group.

To post to this group, send email to

To request to subscribe to this group, please visit the following page:

2. Client server architecture problem (one receiving thread and many activities)


I could think of to implement a dispatcher mechanism  in your thread
where you receive the incoming messages.

I assume that you know which traffic should be routed to which
activity, correct?

You could put the incoming message with an destination identifier
(identifier for the activity) in an thread safe container which is
accessible by the different activities (for example queue record: dest
id, message data).

After the message is placed on a message queue, contact the
corresponding activity that data is in the message queue. The
destination activity would loop through the message queue and be able
to find the incoming messages based on the destination identifier.

Roman Baumgaertner
Sr. SW Engineer-OSDC
T  Mobile stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.


3. BG threads with 1.6; is the AlarmManager starving?

4. change scroll speed in Gallery

5. Pending intent receiverPermission

6. Viewing android Device logs?

7. buttons in list entries