How to toggle "Use Physical Keyboard". - android

I am developing an application where I have RFID reader (emulates keyboard). In some activities I need a virtual keyboard as well. I have discovered that all I need is to toggle "Use Physical Keyboard". That works fine, but when I restart my tablet, this feature is set to default?
Is it possible, if I can insert a toggle somewhere in my code?

I was able to toggle the on-screen keyboard, with the following code:
InputMethodManager inputMgr = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMgr.toggleSoftInput(0, 0);
In reference, use EditText.
"EditText is a thin veneer over TextView that configures itself to be editable."
To display the on-screen keyboard, all they need do is touch in the textbox. If that box was named "Search" or something similar, I believe it would be more useful to a user than a button.

Related

Accessibility does not read the keyboard buttons

I have activated the TalkBack (Accessibility). And I'm navigating for a Screen that is displayed a keyboard in order to write a number in my app.
When I swipe from the left to the right in order to hear all items available the announcement read all my UI components but never jump to the KeyBoard Buttons. So the users will ever know there is a keyboard displayed in the UI.
I have tested on iOS and the VoiceOver is reading the Keyboard properly but seems like Android have an issue.
Does anyone know if there is a way to activate the Keyboard Voice Feedback programmatically?
I'm using this code to show the keyboard.
InputMethodManager input = (InputMethodManager)
activity.getSystemService(Context.INPUT_METHOD_SERVICE);
input.showSoftInput(activity.getCurrentFocus(), InputMethodManager
.SHOW_IMPLICIT);
The keyboard is a separate app in Android. It would need to implement accessibility itself.

Is there an option to have both soft and hard keyboards active?

I am developing a IME keyboard which will have a automobile dial pad as the input handler in android. More clearly, the dial pad turns decide which alphabet to select.if the dial pad is pointed to "a" and then click the center button of the dial pad, it selects alphabet "a".
But my question is, is there a way i can have both hardware and software keyboards active consecutively?
My need is, My dial pad soft keyboard comes up and then i need to test it by right and left arrow of the hardware keyboard.
Thanks in advance
For future users- if you're implementing your own keyboard you can override boolean onEvaluateInputViewShown in InputMethodService. This function controls if the keyboard is shown, and the default implementation is to return false if a hardware keyboard exists. Change it to return true and it will work.
I don't know a way to do it from inside of an app.
for navigation part, i found the solution.
go to settings->input -> default-> disable the hardware physical keyboard.
then if any text edit is used, the soft keyboard comes up and then we can use the physical keyboard to navigate. (only navigation) .

Android, only show custom keyboard

I have an application where I needed to create a custom keyboard since barcode scanners are classified as hardware keyboards and hardware keyboards disable soft keyboards. The issue is that when no scanner is connected, the built in soft keyboard will be displayed when it's not needed. I have a button to show the custom keyboard which will also hide the default keyboard using
((InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(advText.getWindowToken(), 0);
(advText is an extended version of EditText)
I have tried placing that line of code in the onFocusChanged method of the EditText but nothing happens. If I use setInputType(InputType.TYPE_NULL); the android keyboard never shows, but the EditText doesn't display a cursor or anything that is typed from the custom keyboard (but I do know that keys are being stored since my "done" key sends the text from the EditText elsewhere just fine).
I'm fine with disabling the android keyboard completely for this app, just as long as the EditTexts show cursors and custom keyboard is only shown when using the button.
I have looked at these answers, but no luck finding a solution.
Close/hide the Android Soft Keyboard
How to show soft-keyboard when edittext is focused
How to hide Android soft keyboard on EditText
Edit:
My current solution is to run the hide method inside of the EditText's onCheckIsTextEditor since that seems to run after onFocusChanged, and it seems to be called about every second. But this is a nasty hack since the keyboard still shows for a split second and moves my layouts back and forth. My current test devices consist of the Motorola Photon Q 4G LTE with 4.1.2 and a Honeywell Dolphin 70e Black with 4.0.3
EditText provides this functionality with the flag textIsSelectable in EditText set to true. With this, the cursor will still be present, and you'll be able to select/copy/cut/paste, but SoftKeyboard will never show. Requires API 11 and above.
You can set it in your xml layout like this:
<EditText
...
android:textIsSelectable="true"/>
Or programmatically, like this:
EditText editText = (EditText) findViewById(R.id.editText);
editText.setTextIsSelectable(true);
For anyone using API 10 and below, hack is provided here :
https://stackoverflow.com/a/20173020/7550472
Edit your <activity> tag in your AndroidManifest.xml and add this attribute: android:windowSoftInputMode="stateAlwaysHidden" see http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft
Just added that and remove all the other weird things you are doing to hide the soft keyboard.
P.S. You can also enable and disable this feature at runtime. getWindow().getAttributes().softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN;

Android onscreen keyboard without any other keyboard

I've looked at several questions and come across several posts, but i'm not able to figure out how to do this.
The following picture shows you the basic layout :
I've created a custom numpad and put it up on the repo.
Currently, when the app opens, the edit text has the focus but and anything i enter with the keyboard will go into the edittext box. This part of the functionality works fine.
Problem: When i touch the edittext again, system Input Method with its huge keyboard pops up. How do i completely block it from popping up? Or, can i tell the app to use only my keyboard instead of the system one? (Or is the only way to write a custom ime?)
i cannot use NULL type input at the manifest because doing that makes the caret in the edittext disappear and moreover if there are two edit texts, i wouldnt know which has focus.
Any help would be highly appreciated!
You can do a few things:
Programmatically hide it in the whole app:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Hide it from the view it would be attached to:
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(yourEditText.getWindowToken(), 0);
Set the input type of the EditText to 0:
EditText yourEditText=(EditText)findViewById(R.id.editTextConvertValue);
yourEditText.setInputType(0);

Galaxy Nexus' Edit Text not full screen in landscape consistently

In my application, I have a search button which when clicked will make an EditText widget visible, put focus in it, and show the keyboard. When I do this I call this code:
queryTextView.requestFocus();
InputMethodManager imm = Utilities.getInputMethodManagerFromContext(getContext());
imm.showSoftInput(queryTextView, InputMethodManager.SHOW_FORCED);
The first time this shows as I expect it to in landscape:
Once I enter text and hit search, I will hide my EditText and force the keyboard closed. I do this using this code:
InputMethodManager imm = Utilities.getInputMethodManagerFromContext(getContext());
imm.hideSoftInputFromWindow(getWindowToken(), 0);
If I were to hit my button again to make the EdidText visible and show the keyboard again, my screen looks like this (only when using the stock Galaxy Nexus keyboard):
Using another keyboard, such as SwiftKey, I do not get this behavior. What kinds of things can I look for to find out why this soft-keyboard is not filling the screen fully?
EDIT: on second thought, from your screenshots it looks like the keyboard is trying to take up the full screen, so onEvaluateFullscreenMode should be returning true...perhaps the problem is somewhere in onCreateExtractTextView
Not what you're looking for, but if all else fails perhaps you could grap the AOSP keyboard source, walk through it and figure out if/why onEvaluateFullscreenMode is returning, or maybe it isn't being called at all.
Use android:imeOptions="flagNoFullscreen" to achieve that feature.

Categories

Resources