Can an android soft keyboard launch other IMEs - android

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.

Related

How can I get current keyboard language from a service?

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.

How to open android original system keyBoard

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.

Why does the Soft Keyboard appear?

I'm using the Android emulator to test my first Android application. While there is a functioning hard keyboard at the right side of the emulator window, the soft keyboard shows up when editing in an EditText control.
I'm aware of the option to hide the soft keyboard by using an instance of InputMethodManager, however I'm wondering why the soft keyboard does appear at all (when the hard keyboard is available).
To me, as a user, the soft keyboard in this case is rather distracting, hence I'd like to get rid of it if useful. - This question is about the practical context (i.e., is there any use of the soft keyboard when there is a hard keyboard, do real-world devices behave similarly to the emulator) and about general strategies to address the issue.
Thanks. I'll be upvoting any helpful hints.
On my G1, when the hard keyboard was opened, the soft keyboard didn't appear. But I'm not sure whether a device which ALWAYS has a keyboard opened (like the Samsung Galaxy PRO if I'm not mistaken) does the same.
Since the emulator doesn't have a slide keyboard, I think that's the case for this behavior.
With a touch screen device + hard keyboard you have the flexibility to use both. On most devices with hard keyboards the keyboard has to be dragged out. It's much easier to just tap the screen. If you want to type a lot you would take the trouble to slide the keyboard out.
Android gives you the flexibility to program for all these behaviors.
Actually, the AVD emulator does have a slide-out keyboard.
The AVD option "Keyboard support" indicates whether the emulated device has any form of physical keyboard. The option "Keyboard lid support" indicates whether the device has a keyboard that can be opened or closed (slid out or what have you).
As far as actually "opening" and "closing" the keyboard on a device set up with these options,
you need to switch the orientation which is generally what you do with real-world slide-out-keyboard phones, e.g. the original Droid:
Original Droid with slide-out keyboard open
In the emulator, you control this orientation change with Ctrl+F11/Ctrl+F12 or 7/9 (on the number pad only, with NumLk off).
You can confirm the keyboard opening and closing states by checking the value getResources().getConfiguration().hardKeyboardHidden == config.HARDKEYBOARDHIDDEN_YES
As far as whether the soft keyboard appears or not, it appears to me that handling such things is up to you as the programmer. Here's an example you can try in AVD:
Set up an emulator with "Keyboard support" and "Keyboard lid support" both set to yes.
Launch the emulator, then open Android's built in Messaging app.
Click in one of the text boxes - the soft keyboard should show up.
Switch the orientation of the emulator with Ctrl+F12 - the soft keyboard should now disappear
Note there seems to be a problem with the emulator itself, that switching back to portrait mode doesn't cause apps to redraw themselves back to portrait layout. but they will switch back to closed keyboard mode, which yields some odd, sideways-y behavior.
For an example of code to catch the keyboard opening/closing events, check out: http://www.how-to-develop-android-apps.com/how-to-detect-screen-orientation-change-in-android/
After testing on real world devices; On the motorola milestone that has a sliding keyboard that if it's open the soft keyboard is not shown, but when it's closed the soft keyboard is shown. On the HTC Cha-Cha, that has a permanently shown keyboard, the phone always uses the hardware keyboard. Even when in landscape and the hard keyboard would be very difficult to use it doesn't show a soft keyboard (Even after installing a soft keyboard I was unable to select it for use under Keyboard & Language Settings).
For additional information about the phone you can use the following.They will return the keyboard type and whether or not it is a hard keyboard and shown. Note: Phones without a hard keyboard that I've tested report that hardKeyboardHidden=2; (Which indicates hidden=yes), but type reports as soft keyboard which makes sense.
Configuration config = getContext().getResources().getConfiguration();
int keyboardHidden=config.hardKeyboardHidden;
int keyboard=config.keyboard;
http://developer.android.com/reference/android/content/res/Configuration.html#HARDKEYBOARDHIDDEN_NO

Android: How to intercept keydown globally (on hardware keyboard)

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..

can one prevent the Android device emulator from popping up the onscreen keyboard?

I am developing an Android application. What I find most annoying during testing is, that the emulator always pops up that on-screen telephone keyboard whenever I click into a text input field. Since I input my data with the keyboard anyway I find that most annoying. Can one switch that on-screen keyboard appearance off? Or can one change that so that it at least presents a mini-qwerty keyboard as my actual device does, not that old-fashioned T9 keyboard?
Michael
You can disable the virtual keyboard in Settings->Language.
If you change orientation of the emulator it won't popup (KEYPAD_7, Ctrl-F11).
If you use cursor keys instead of clicking the fields, probably won't popup either.
Whatever you do, keep in mind that in actual devices it usually pops up anyway.

Categories

Resources