Can't get cursor position from InputConnection

by nattster » Fri, 20 May 2011 09:30:36 GMT

Sponsored Links
 I'm developing an Input Method. 
I'd like to change cursor position with 
*InputConnection.setSelection< #setSelection(int,

This method allows me to set absolute position of cursor.
But what I want is to move cursor relatively from current position.
(e.g. Move left 3 characters from current position)

I can't find method to get current cursor position.
Currently, I got this hack:

    InputConnection conn;
    CharSequence seq = conn.getTextBeforeCursor(1000, 0); 
    // will get as much characters as possible on the left of cursor

    int cursor_pos = seq.length();

Is there any better way to do this?
Should we introduce new method to InputConnection, i.e. getSelectionStart?


Other Threads

1. Require J2ME (Android) developers with hands on experience in Blackberry & Android for Catalytic Software Limited (CMML5)

Currently, we are looking for J2me Developers with 2 to 4 years of

Skill set:- J2me, BlackBerry, Android, MIDP, API

Job Location:- Hyderabad

You can read more about Catalytic, the people, and philosophy by
visiting our corporate website at

I request you to kindly send your updated resume with current,
expected salary details and earliest available date to assume work to
initiate the discussions to


2. Can the packages which begin with "" be used for free?

Can the packages which begin with ""  be used for free? Such


3. DHCP request failed wifi with WEP2 enterprise

4. Accessibilityservice

5. Playing Audio file to the caller

6. How to cache mapview tiles?

7. Where is the aapt.exe in SDK 1.5 and 1.6