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. writing to sd card issue

Hi all

I am trying to write to SD card without
"android.permission.WRITE_EXTERNAL_STORAGE" permission in manifest
file. I am able to write to sd card.

Whether I have to mention this permission in application manifest or i
have to mention in other places also. What other factors I have to
look in to this.

Gururaja B O


2. Contacts.apk

I'm completely new in android environment. So, I want to ask for a
solution which is probably very noobish question to you people. :D

I want to replace the contacts.apk file in system/app/ . I go through
"adb remount" and then push. But when I reboot emulator, everything is
default. So, how can I change the system files in emulator (e.g. i
want to change the color of status bar or change the dialer background
and whatever.)

I'm using android 2.1 emulator.


3. file handling : reading a file in internal storage

4. WebView always appears FULLSCREEN

5. Consolidating two SharedPreferences issues.

6. RTCP BYE packets not supported by the Android Media Framework?

7. Problem with app after update to 2.2