Android Onscreen Keyboard Won't reappear

I’m having some Android keyboard problems. The first time I focus a texteditor control, the keyboard shows. I’m using the trick from this thread to hide it when a submit button is pushed:

But then the keyboard doesn’t re-appear when the same texteditor or another gets the focus.
I’m in fullscreen and kiosk mode, but that doesn’t stop the first appearance. Any trick to manually show and hide it? I can tolerate that in this app.

Have you tried this on an actual device? This code is working fine for me on a Moto G6 Plus:

 The block below describes the properties of this PIP. A PIP is a short snippet
 of code that can be read by the Projucer and used to generate a JUCE project.


  name:             AndroidTextEditorFocus

  dependencies:     juce_core, juce_data_structures, juce_events, juce_graphics, juce_gui_basics
  exporters:        androidstudio


  type:             Component
  mainClass:        MainComponent



#pragma once

class MainComponent   : public Component
        addAndMakeVisible (edit);
        addAndMakeVisible (hideButton);
        hideButton.onClick = [] { Component::unfocusAllComponents(); };
        Desktop::getInstance().setKioskModeComponent (getParentComponent(), false);
        setSize (600, 400);
    void paint (Graphics& g) override
        g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
    void resized() override
        auto b = getLocalBounds().reduced (20);
        hideButton.setBounds (b.removeFromTop (35).reduced (20, 0));
        b.removeFromTop (20);
        edit.setBounds (b);
    TextEditor edit;
    TextButton hideButton { "Hide" };

Thanks for the example - like the PIP thing!

So - on a Galaxy Tab S4, the keyboard appears the first time, hides as intended, but never comes back.

Same on the simulator set to version 27.

Hi, did you type anything when you tested? If I just go focus/hide/focus, that works. But as soon as you enter anything in field, it’s gone.

Here’s a clue: if there’s something in the text field it will not show up. A blank text editor given focus will show a keyboard, an editor with contents will not.

This is obviously a show stopper on Android.

I can maybe blank the fields and let the user enter stuff, but they would be unable to go back and edit a typo if they move focus.

Ah, that was it. I’ve pushed a fix to develop here that should fix the issue.

1 Like

Great, thank you - works perfectly!

OK, damn.,%20java.lang.String)

setInputMethod is marked as deprecated in API 28. Maybe someone got keen and pulled it early? Or is it that the strings don’t match/changed - I can’t find that list. Trying to get to it in debugger now.

This guy claims it’s a security thing?

@ed95 Ed - any idea why when you show the keyboard, you also get the top status bar (carrier, wifi etc.) as well?
Not a huge problem, but it looks messy when you hide it - there’s a notable resize as kiosk mode kicks in, then if openglrenderer is enabled, there’s a wicked glitch as it resizes too.

Edit - using @android:style/Theme.Holo.NoActionBar.Fullscreen instead of @android:style/Theme.NoTitleBar prevents the status bar re-appearing with the keyboard, but the nav bar still appears, so there’s still a glitch or a black bar at the bottom that redraws badly sometimes, and still the wicked glitch sometimes.

Maybe the relevant bug report would be: nasty glitch on android with OpenGL renderer enabled when window resizes. The normal renderer is fine, but of course any component animation is out.

I can add this to our backlog but it sounds like something that will take a while to track down. For the time being are you able to attach your OpenGL context after the window is put into kiosk mode to avoid the resizing glitches?

It resizes (and often glitches) every time the keyboard appears and disappears, so not really.

For now I turned off gl and therefore animation.