When I try to use ANativeActivity_showSoftInput()
, it doesn't bring up the soft keyboard.
I have tried using ANativeActivity_showSoftInput(engine->app->activity, ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED)
and ANativeActivity_showSoftInput(engine->app->activity, ANATIVEACTIVITY_SHOW_SOFT_INPUT_IMPLICIT)
to show softinput, but also failed.
I read the source code, and I found after start nativeActivity
, NativeContentView(extend View)
will be created, and when call ANativeActivity_showSoftInput
, it will call showSoftInput()
in java side. I think maybe the softkeyboard is not turned on.
Can you help me?
I have got exactly the same problem. No way to show the Keyboard using this API.
The only way I found was to use JNI but of course I am not satisfied with that solution:
I had a lot of trouble trying to close the soft keyboard when the view changed, until I realized I had to remove it specifically from the view that called it:
There's also a showSoftInput method that should probably work (assuming it does what the method name says it does) in a similar way, where it needs a view to anchor itself to:
Can't really test this myself at the moment, but I figured it might be able to help you and would be worth a shot. Just make sure the "editText" is linked to the EditText you want to receive the input.
Another way is to go with a hybrid solution where you extend the NativeActivity in java and have helper functions for showing and hiding keyboard.
And on the native side...
This allows you to deal with the Android specific stuff in java as it was intended and have the native code call into wrappers, thus reducing the complexity in syntax on the native side.