1

How open (switch, set) softkeyboard from my service?

My application is not consist any activity. But i try open softkeyboard on trigger in my service, when alient application is onscreen. I find in InputMethodManager's method setInputMethod. Second argument is id of keyboard. I know it. But first argument is IBinder. What is IBinder argument in my application?

Add detail:

My application consist of Service and InputMethodService.

In Service - Analyzing starting application in system. In InputMethodService - my softkeyboard (IME). If in my Service i determine what is start right application (I dont own this application), I need to switch current softkeyboard to my InputMethodService's IME. Only switch, but not open keyboard. And when user tap on editabled view in client application, system open my soft keyboard.

Praful Bhatnagar
  • 7,425
  • 2
  • 36
  • 44
Tapa Save
  • 4,769
  • 5
  • 32
  • 54
  • why do you want to do that? – Praful Bhatnagar Dec 21 '12 at 07:59
  • @Praful Bhatnagar, Short: my service analize starting of any applications in system, and i need start desired keyboard when starting right application. – Tapa Save Dec 21 '12 at 08:05
  • ahh really sorry but I still don't understand the requirement.. can you please elaborate more on the requirement.. – Praful Bhatnagar Dec 21 '12 at 08:09
  • Add detail: My application consist from Service and InputMethodService. In Service - analising starting application in system. In InputMethodService - my softkeyboard (IME). If in my Service i determine what is start right application (I not own for this application), i need switch current softkeyboard to my InputMethodService's IME. Only switch, but not open keyboard. And when user tap on editabled view in alient appliation, system open my softkeyboard. – Tapa Save Dec 21 '12 at 08:25

1 Answers1

0

My solution code in Service:

    ((InputMethodManager) contextService.getSystemService( Context.INPUT_METHOD_SERVICE)).setInputMethod( null, myInputMethodId);
    ((InputMethodManager) contextService.getSystemService( Context.INPUT_METHOD_SERVICE)).toggleSoftInputFromWindow( null, 1, 0);

p.s. This work only if my application is a system (null in first argument in setInputMethod available only when my application is system). I programmatically get system privilegies for my app with mv /data/app/myapp.apk /system/app/myapp.apk (basis on https://stackoverflow.com/a/14257161/1665964).

Community
  • 1
  • 1
Tapa Save
  • 4,769
  • 5
  • 32
  • 54