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.
Related
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.
Thanks in advance for the help.
I am developing an android application for research purposes and need to disable the speech to text button on the soft input keyboard. The reason for this is due to concurrency issues that arise since the application I am developing uses the microphone. I understand that for a general application disabling keys is generally seen as impossible (since users may change default keyboards). I know for a fact that the default keyboard will be used.
With this in mind is it possible to disable certain keys? I believe that at the least I should be able to specify the input type such that the microphone button is hidden. I say this because if I disable speech to text in the settings (not programmatically, but manually as a user) the microphone icon is removed from the keyboard. I'm open to any possible solution (with the exception of not using the default keyboard) as this application will not appear on the play store.
You can't force the user input through anything other than pre-defined keyboards that already exist in the user's device.
The only way you could get around this is by programming your own custom, on-the-fly keyboard, and that is a very bad idea.
Just disable voice input programmatically by using XML declarations in the EditText you're looking at. You can do this with the attribute:
android:privateImeOptions="nm" // nm stands for No Microphone.
If you want to set it programmatically you can try this::
// deprecated i guess
edt_txt.setPrivateImeOptions("nm");
// this one is new but it works only with Google Keyboard.
edt_txt.setPrivateImeOptions("com.google.android.inputmethod.latin.noMicrophoneKey");
You can combine values in PrivateImeOptions parameter in CVS form so best option is to use:
edt_txt.setPrivateImeOptions("nm,com.google.android.inputmethod.latin.noMicrophoneKey");
Take a look through here and see if you can find what you're looking for.
More info about Google Keyboard here -> look for method setOptions
To disable microphone button on multiple keyboard. Use property
android:privateImeOptions="nm"
But it will not work for Gboard(google native keyboard)
To disable on microphone on Gboard use
android:privateImeOptions="nm"
editText.setImeOptions(IME_FLAG_NO_PERSONALIZED_LEARNING)
Just use this in your editText on the layout file:
android:imeOptions="flagNoPersonalizedLearning"
I want to make an application to automatically change my mobile keyboard according to application. My mobile default keyboard will change according to application, such as:
I want to use "Ridmik Keyboard" with Facebook or want to use "Swift keyboard" with Google play. Is it possible ?
I'm pretty sure that it's not possible. The only way you can change the keyboard is by asking the user to do so from the device's settings. Automatically changing the keyboard would be a major security hole, as a malicious keyboard could track passwords, for example.
Alternatively, you could ask the user to select a keyboard by calling startActivity(new Intent(android.provider.Settings.ACTION_INPUT_METHOD_SETTINGS));, and you can detect when a certain application is launched by sniffing into the LogCat.
If you are willing to root your device there are at least two solutions in the Google Play store that claim to do what you want: Keyboard Manager and Keyboard Master.
For non-rooted devices, there is Keyboard Manager Plus - however you should be aware that it flashes the keyboard picker on the screen as it automatically changes the keyboard. If you can live with that, that's a possible solution for you without rooting.
Caveat: I have not tried these myself. I am researching the issue and I do not have the option of rooting the device and I cannot live with the flashing. However, I've taken a pretty close look at all three of the above and they are the closest I've found to answering your question.
I have a login screen on my app which accepts a CPF as login (CPF is an unique number identification that every Brazilian citizen have, e.g: 10546819546), but it can also accept passport numbers as the login, and these may have letters on it.
My problem is that I want the keyboard, when it pops up, to show to number/symbols "view" before the default alphabet one. Changing the inputMethod to phone or number does not solve my problem, because as I said, the login may contain letters.
I've seen some explanations to questions somewhat similar to mine but all of them either didn't solve my problem or it was too overcomplicated.
This is merely a small adjust to slightly improve user experience and entertain me developing the app, so if the solution is something like "override the default keyboard, make a custom component" etc, I'll just leave it alone.
TL;DR: I want to show the number/symbol soft keyboard before the letters one.
Unfortunately when it comes to the soft keyboard you are somewhat at the mercy of whoever made the one the user has their device set to. Lots of devices come pre-loaded and defaulted to the swype keyboard. But many others have soft keyboards that were made by the manufacturer of that device. It it up to whoever created it to decide how the keyboard reacts to the android:inputType that you pass to it. It is possible that some of the ones out there right now actual have the behavior you are looking for when you set them to number or phone. I just checked it out on my sidekick and found that it was the same as yours both number and phone provided no way to input letters.
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..