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. label on the left for RadioButton


by default the label of a RadioButton in on the right of the
checkMarck. Is there a way to put the text on the left ?



2. android manifest file from an unzipped apk cannot be read

I would like to read the android manifest from an apk file. I unzipped
it using 7-zip. However, the manifest seems to be in binary with some
ascii but a lot of control chars. Was it meant to be hidden? The
philosophy behind Android is to share and reuse activities - but if
the manifest cannot be read, then I dont know how it can be done.


3. change string resource folder

4. Adding Feature to Android (that I've made)

5. Help! Strange exception on HTC Hero

6. Facing licensing issue in already published paid app

7. External Storage Vulnerable