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. how to identify the views part of the current screen

Hi All,

Can anyone give an idea how to identify the views part of the
active screen[i.e current running activity on the phone].

E.g after launching uiEditContactActivity,how can I identify the views
[ several fields, buttons etc]
part of that screen.

I am trying to modify monkey, such that for creating a contact, it
should launch Edit Contacts Activity and fill the respective views
[name, number etc].



2. Splitting connections?

I have an app that runs on a closed network with no internet access.
I connect to it through wifi.  My app also uses Google Maps.  Is there
a way to make the MapView still pull from my 3G connection while the
rest of the app uses the wifi?  The issue is once connected to the
wifi, maps tries to pull from the internet and can't get there so my
MapView is always blank.


3. Showing List of image in <AbsoluteLayout>

4. answer call using acceptCall() of

5. getting the serial number

6. How to change language settings

7. Using WifiManager to connect to a network