I have some problem when I'm working with InputMethodService.
First situation, I create an Activity that has 2 EditText. I'm focus
on first one and run InputMethodService function for entering
"HelloWorld !!!". The command line is :

getCurrentInputConnection().commitText("HelloWorld !!!",1);

It seem to be no problem. Then, I call this line:

sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_DOWN);

The pointer comes to the second EditText. Then i call :

getCurrentInputConnection().commitText("Hello !!!",1);

The string "Hello !!!" is typed in the first EditText. Why happen
this???

The second situation, I change the commitText() function to me
function that use 2 method, sendDownUpKeyEvents(KeyEvent) and
sendKeyChar(char) for typing each character.
I write like this :

                                                   for(int
i=0;i<typeString.length();i++){
                                                        char c = 
typeString.charAt(i);
                                                        if(c>='0' && c<='9'){
                                                                keyEventCode = 
c-'0'+KeyEvent.KEYCODE_0;// character-ASCCII
code+Android key code
                                                                
sendDownUpKeyEvents(keyEventCode);
                                                        }
                                                        else if(c>='a' && 
c<='z'){
                                                                keyEventCode = 
c-'a'+KeyEvent.KEYCODE_A;
                                                                
sendDownUpKeyEvents(keyEventCode);
                                                        }
                                                        else if(c>='A' && 
c<='Z'){
                                                                
getCurrentInputConnection().sendKeyEvent(
                                                                new 
KeyEvent(KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_SHIFT_LEFT));
                                                                keyEventCode = 
c-'A'+KeyEvent.KEYCODE_A;
                                                                
sendDownUpKeyEvents(keyEventCode);
                                                                
getCurrentInputConnection().sendKeyEvent(
                                                                new 
KeyEvent(KeyEvent.ACTION_UP,
KeyEvent.KEYCODE_SHIFT_LEFT));
                                                        }
                                                        else{
                                                                boolean 
isManaged = true;
                                                                switch(c){
                                                                        case 
','://comma
                                                                                
keyEventCode = KeyEvent.KEYCODE_COMMA;
                                                                                
break;
                                                                        case 
'*'://start
                                                                                
keyEventCode = KeyEvent.KEYCODE_STAR;
                                                                                
break;
                                                                        case ' 
'://space
                                                                                
keyEventCode = KeyEvent.KEYCODE_SPACE;
                                                                                
break;
                                                                        case 
'-'://minus
                                                                                
keyEventCode = KeyEvent.KEYCODE_MINUS;
                                                                                
break;
                                                                        case 
'='://equals
                                                                                
keyEventCode = KeyEvent.KEYCODE_EQUALS;
                                                                                
break;
                                                                        case 
'['://left bracket
                                                                                
keyEventCode = KeyEvent.KEYCODE_LEFT_BRACKET;
                                                                                
break;
                                                                        case 
']'://right bracket
                                                                                
keyEventCode = KeyEvent.KEYCODE_RIGHT_BRACKET;
                                                                                
break;
                                                                        case 
'#'://pound
                                                                                
keyEventCode = KeyEvent.KEYCODE_POUND;
                                                                                
break;
                                                                        case 
'/'://slash
                                                                                
keyEventCode = KeyEvent.KEYCODE_SLASH;
                                                                                
break;
                                                                        case 
'\\'://back slash
                                                                                
keyEventCode = KeyEvent.KEYCODE_BACKSLASH;
                                                                                
break;
                                                                        case 
';'://semi colon
                                                                                
keyEventCode = KeyEvent.KEYCODE_SEMICOLON;
                                                                                
break;
                                                                        case 
'\''://APOSTROPHE
                                                                                
keyEventCode = KeyEvent.KEYCODE_APOSTROPHE;
                                                                                
break;
                                                                        case 
'+':
                                                                                
keyEventCode = KeyEvent.KEYCODE_PLUS;
                                                                                
break;
                                                                        case 
'`':
                                                                                
keyEventCode = KeyEvent.KEYCODE_GRAVE;
                                                                                
break;
                                                                        case 
'.'://PERIOD
                                                                                
keyEventCode = KeyEvent.KEYCODE_PERIOD;
                                                                                
break;
                                                                        
case'@'://AT
                                                                                
keyEventCode = KeyEvent.KEYCODE_AT;
                                                                                
break;
                                                                        default:
                                                                                
isManaged = false;
                                                                                
break;
                                                                }

                                                                if(isManaged){
                                                                        
sendDownUpKeyEvents(keyEventCode);
                                                                }
                                                                else{
                                                                        
sendKeyChar(c);
                                                                }
                                                        }
                                                }
 Then I come back to the first job.
I call : MyFunction("HelloWorld !!!");
The text is typed to the first EditText. Okie now.

Then I call sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_DOWN);
The pointer comes to the seconds EditText.

Then I call MyFunction("HelloWorld2 !!!");
The string "HelloWorld2" is types in the second EditText, and, oh my
god, the string" !!!" is type in the first EditText.

why this happen ???How can I resolve this situation.

The third situation, I start an program with the "am" command , then I
call InputMethodService to type some text. And I get the message like
this : "InputMethodService: starting input on non-focused client in
com.android.internal.view.iinputmethodclient$stub$pr...@..." and
nothing is type in the application. How can i resolve this???

Thanks for your help!!!!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to