I want to make a layout icon for Android phones with QWERTY keyboards, however Android policy concerning InputMethodManager is pretty strict, so I am trying to get the current language via the Accessibility, but I am stuck since the provided AccessibilityService.SoftKeyboardController can only tell you if the keyboard is shown.
Any ideas on how I can get the current layout from a service?
I found a workaround - when the layout changes a Toast notification is shown, so I've resorted to catching these notifications. It's a hack, but it works.
Related
I have an application that works fine with android "original" default keyboard but has issues with some custom keyboards.
Is it possible to always pop-up the android "original" keyboard regardless the has user installed a custom keyboard?
I know the best way is to write my own keyboard class but currently I don't have the time and I need a quick fix.
Thanks.
I am developing an simple game using soft keyboard where people play with characters. So I want to change the background color of keys during the game. I know that there are tones of tutorials and questions out there answering to changing background and color of keys but my question is a bit different. Because I want to do it dynamically and I have had a hard time to figure out that how can I do it. I am using Android soft-keyboard but I don't know where and how can I add a listener to change the corresponding key's background. And how my game-engine sends this signal to the keyboard? Could you help me what should I do?
Thanks
Changing the appearance of the soft keyboard from your app will likely be impossible, especially on a per-key level as you describe.
The most feasible option would be to create a custom keyboard specifically for your application.
You could possibly get in touch with the developer of a keyboard app but it's unlikely they'd be willing to add a back door just for your game- and even if they were, your users would then be required to install that keyboard to play your game, which is not ideal.
I thought about implementing kind of a meta-soft-keyboard for android that first checks if a physical keyboard is connected (in my case a dock but bluetooth kbds should also be possible) and launches a specific other soft-keyboard if there isn't.
So:
Is there a way to get a list of all installed keyboards using the android API?
/edit: This seems to be possible using the InputMethodManager
Can I then call a specific one of these keyboards?
If there is no API solution, can it possibly be done on rooted phones/tablets?
Or do I have to implement my own full keyboard solution (or possibly fork/improve an existing open source one) that just doesn't pop up when there's a physical kbd connected)?
For those having similar troubles:
The best work-around solution I found so far is using the NULL keyboard and the Dock keyboard switcher apps. But the NULL keyboard currently only supports the english layout and the constant keyboard switcher popup gets kind of annoying... (IMO it's almost easier to just hide the keyboard everytime it appears)
Seems like it can be done by public boolean switchToNextInputMethod (IBinder imeToken, boolean onlyCurrentIme), but I don't know is it switching permanently or only for one time and this method is added only in Jelly Bean.
How can I detect which language is use typing into EditText. I know the API 13 has getCurrentInputMethodSubtype, but what is the alternate for older versions?
There is none. And I wouldn't count on even that above working across all keyboards. I wrote a popular keyboard and have no idea where the framework would get that info from- there's no API for them to query what keyboard type we are or for us to update if we switched (say from a user using an in keyboard switch language shortcut).
The keyboard API is really Google's bastard stepchild. They don't seem to put a lot of thought into it, or work with other major keyboard makers when adding new functionality.
Is there a possibility for an android app to run as a service in the background, intercept keydown events from the hardware keyboard and change behavior (i.e. the resulting character) in some special cases?
The idea in mind is to have sort of a keyboard layout fix, mainly making important special characters available using an alternative keymap instead of having to select from a huge grid on the touch screen. Sometimes, the default keymap of a mobile devices do not represent all important characters, even more when it comes to non-english languages.
Thanks for inspiration :)
Peter
EDIT: additionally emphasized hardware
What you are describing is in fact not a service in background but replacing the keyboard app itself..take a look at the SWype app.
You do not have to create a service to do this as you want just the your own keyboard layout coming up when entering text, etc.
The sample of replacing a default app in the sdk is the homescreen but the keyboard app can be replaced as well..