[SOLVED] Extension Suggestion: Hide System Keyboard

@TIMAI2 sorry for that let me check tomorrow

2 Likes

Use this extension
KeyboardHandler.aix (5.2 KB)

1 Like

Use this method from Android Developers. I guess Faraz used the same way.

InputMethodManager | Android Developers

2 Likes

I just made KeyboardHider according to the Android Developers documentation. @AyProductions, if you agree to make this open source (OS), I will.

image

Downloads: com.gordonlu.keyboardhider.aix (6.5 KB)

2 Likes

This extension should be open source as there is a 1/10 chance the keyboard might pop up

I was planning to merge my extension with the Device extension. Is that OK?

That way, you will no longer need to download multiple extensions.

@Gordon_Lu I have used same method. I think this extension should be open sourced

1 Like

Good.

  1. Import these:
import com.google.appinventor.components.annotations.SimpleFunction;
import android.view.inputmethod.InputMethodManager;
import com.google.appinventor.components.runtime.AndroidViewComponent;
  1. Then use these:
    @SimpleFunction(description = "Hides the soft window, but the soft input window should only be hidden if it was not explicitly shown by the user.")
    public void HideImplicitOnlyFromWindow(final AndroidViewComponent textBox) {
        ((InputMethodManager)this.context.getSystemService("input_method")).hideSoftInputFromWindow(textBox.getView().getWindowToken(), 1);
    }
    @SimpleFunction(description = "Hides the soft window, but indicates that the soft input window should normally be hidden. The keyboard will be hidden unless "
    + "the user has forced the input method open (such as by long-pressing menu) so it should not be closed until they explicitly do so.")
    public void HideNotAlwaysFromWindow(final AndroidViewComponent textBox) {
        ((InputMethodManager)this.context.getSystemService("input_method")).hideSoftInputFromWindow(textBox.getView().getWindowToken(), 2);
    }

Look back the Google documentation to look at why the values are 1 and 2.

1 Like

@AyProductions Can I merge my extension with the Device extension?

1 Like

This extension (also the one from @Faraz_Firoz) is not hiding the keyboard for me in companion on Android 12. When I touch in a textbox the keyboard comes up.

1 Like

it would be better to merge

@TIMAI2 i guess android 12 for some reason restricts that? or maybe i think we need to ask for a permission!! which i dont know...

or we may have to build the apk and then test it!

Your extension (if it worked for me) does not appear to have an escape block, in order to return keyboard functionality ?

1 Like

No it doesn’t.

There are two different blocks in my extension, hiding the text box under different situations. What block are you using?

1 Like

Tried both. Neither works. Also compiled my test app, same issue.

Perhaps show me your working blocks....

That’s strange - the method wasn’t deprecated on Android 12. I will try to figure out the issue.

1 Like

This hides the keyboard on Android 11 & 12 for me when touching in a Textbox with Companion.

grafik

2 Likes

I also used the same method.

But all that does is the same behaviour as this:

image

If I tap in the textbox, the keyboard comes up again

It does not doable the keyboard, it only hides the keyboard.