I have my own portable C++ ui engine, with my own implementation of text edit fields. I can display a native keyboard, and get and process key events. However, I want to control the type of soft keyboard displayed - so if the edit field is for a phone number, show the appropriate numeric keyboard. In a standard java app you do this by setting the inputType property of an EditText element in a view. I don't have an EditText element, but want to specify the equivalent settings somewhere to control which native keyboard is show. I am happy using JNI and Java interfaces - I just need to know what to set where.
Sorry - I am not sure I understand this. The example you reference is calling the setInputType function through a variable named password, which references an EditText element. At least that's how I understand it. I don't have an EditText element. My problem is finding some object in the input method system which has an interface to set the input type.
Thanks for the links. It looks like the crucial part is overriding the onCreateInputConnection function of the View class. Looking at the java implementation of NativeActivity, it creates a NativeContentView subclass of View. I can't see any way to replace this with my own subclass, so that I can have an implementation of onCreateInputConnection. Is there any way to do that?
I have no idea how to access a private java data member from C++ code.
I don't see how cloning/rewriting NativeActivity would work - the implementation calls a lot of private native functions for which I don't have the source code. I don't know how I would be able to declare and call them from my own version of NativeActivity.
I'm surprised this issue hasn't been solved before. Do other folks not try to mix native software keyboards with their GL native apps? Or if they do, do they not try to control the input type?
It would certainly be easier to implement a soft keyboard in my own ui, but I wanted to let the user use the one they might be familiar with.
KRJon
I've been trying to extend the nested NativeActivity.NativeContentView class, but this has package private access, so I couldn't extend it in my own package.So I then tried redefining my subclass of NativeActivity to be in the android.app package. I moved the files from com/mycompany folders into android/app folders - (but still below my app's src/main/java tree). Any references to package private members of NativeActivity still generate 'can't resolve symbol' errors. I guess whatever file holds all the android class symbols and definitions doesn't export package private symbols, because that file is supposed to hold the complete package, and those symbols shouldn't be accessed outside it?Is there a trick I'm missing here?
I'm reluctant to go the route of cloning the whole NativeActivity class. It would not be future-proofed if the standard implementation changes in the future, and it seems a lot of effort for such a simple item of functionality.