App with own soft keyboard by default - android

I'm creating a app and want him to have his own custom soft keyboard by default, but I don't know how do this.
So far I have the app and a separate app for the keyboard, I tried to set the custom keyboard by default but don't managed to do that, the only way I found for enable him is via shell and enabling manually in the phone configuration, the shell command that I use:
ime enable package/appName
ime set package/appName
I tried to execute this commands via:
Runtime.getRuntime().exec();
Tried to put in the init files too, tried to substitute the default android keyboard, but nothing works.
If anyone can help me you have my thanks.

Related

Disable speech to text button (Micro phone) on soft input keyboard in android programmatically

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"

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.

Detect or Suppress Keyboard in UiAutomator Tests

In my UI tests I am setting the text of two UiObjects near the top of the screen, and clicking on third UiObject which is located near the bottom of the screen. On some devices (eg my Nexus 6 running 5.0) this works perfectly. The text is set, the UiObject at the bottom of the screen is still visible, and it is successfully clicked on.
On other devices (eg my Nexus 4 running 4.4) calling setText on the UiObjects brings up the soft keyboard, which obscures the third UiObject near the bottom of the screen and prevents it from being clicked on.
I considered using UiDevice.pressBack() to dismiss the keyboard, but the problem is that the keyboard shows on some devices and not others. Pressing back on the devices that do not show the keyboard causes other behavior which leads to the test failing.
I also considered using UiDevice.pressEnter() as a solution. I figured this would dismiss the keyboard if it was visible, and do nothing if it wasn't (best of both worlds). The problem is, that the keyboard shown by UiAutomator when it is running my tests does not have an "enter" button, it has a "next" button. This is contrary to the way I have the actual UI elements setup in code though. When I test this manually the keyboard shows the "enter" button as expected. However, since UiAutomator is seeing the "next" button, that is the functionality it is executing. The focus simply passes to the next UiObject and the keyboard is still visible.
So what I am trying to do is dismiss the keyboard IF it is visible, without risking pressing the back button if it is not. Is there a way to determine if it is showing or not? Or better yet, never show it in the first place?
Different device have different packages, and keyboards function may different too.
So, the details may not be all the same.
Steps listed below are succeed in Android 4.0+ on my device:
Disable packages relative to keyboard input method.
The commands are listed here:
adb root
adb shell pm disable com.google.android.apps.inputmethod.hindi
adb shell pm disable com.google.android.inputmethod.korean
adb shell pm disable com.google.android.inputmethod.pinyin
adb shell pm disable com.google.android.inputmethod.latin
adb shell pm disable jp.co.omronsoft.iwnnime.ml
pause
Note: Some package name like "com.google.android.inputmethod.pinyin" may not exist in device.
Use this command to check:
adb shell pm list packages inputmethod
Disable the "Google voice typing"
"Google voice typing" can still popup the keyboard.
If you want to disable keyboard:
Go to Settings → Apps → Running (or All) → "Google Keyboard" → Settings → Disable "Google voice typing".
Note: If you want enable the keyboard, run command like this:
adb shell pm enable com.google.android.inputmethod.latin
I guess I found a way to make the tests pass, which is to simply scroll the screen down further. In my case the UI is scroll-able, so this works.
UiScrollable layout = new UiScrollable(new UiSelector().resourceId(...));
layout.scrollForward(5);
I am posting this in case it helps anyone in a similar situation. It does not actually answer my question though, so I am not accepting this.
I think maybe you can try this : Write a if() on that step , if cannot find the UiObject in that view ,then UiDevice.pressBack().

Add my own custom keyboard to specific edit text

I came to a big problem. I have my own custom keyboard. My goal is to use this keyboard in my other application.
First I tried to set this keyboard as a default device's keyboard programatically. I could do it through adb shell with no problem. But couldn't make it from app using Runtime.exec(). Unfortunately the device is not rooted.
I can use this keyboard when i enable it in settings and then set it as default input method, but I have to do it manually.
So now I would like to set this keyboard to all EditText's in my other application. Is this possible ? Thanks for any help.
Is this possible ?
No. The user gets to choose the input method editor, not you.

android softkeyboard sample code does not change keyboard

I loaded the android Sample code for Softkeyboard onto my Nexus. It shows me the option of picking the Soft KeyBoard Service under settings->language->keyboard. I select the new service and also a language, but when i go to the web browser and focus on the url field I get the same system keyboard popping up, nothing different. Has anyone tried the sample project and got a different looking keyboard? Is there something I'm missing when running the apk?
Have you checked available input methods? Just touch and hold on any text field (<4.0) or open notification bar and choose input method while keyboard is opened.

Categories

Resources