Discussion:
How to select the type of native soft keyboard displayed in native application
j***@gmail.com
2018-05-22 09:33:06 UTC
Permalink
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.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/ff2ebe30-d53b-4e89-bd9c-2ee6b943f5e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Alex Cohn
2018-05-24 13:04:49 UTC
Permalink
Post by j***@gmail.com
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.
You can set InputType
<https://developer.android.com/reference/android/text/InputType#TYPE_CLASS_PHONE> without
EditText, see e.g. https://stackoverflow.com/q/9892617/192373

BR,
Alex
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/51259db1-15c1-4815-bd6a-671a0114edb5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
j***@gmail.com
2018-05-24 17:03:34 UTC
Permalink
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.

KR
Jon
Post by j***@gmail.com
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.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/58d7b77f-17a6-4275-8987-b68f6fa1cb4f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Alex Cohn
2018-05-26 09:01:55 UTC
Permalink
Post by j***@gmail.com
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.
Sorry, wrong link (I had too many tabs open at a time). Try this one
<https://stackoverflow.com/questions/44664835/android-custom-view-with-type-class-number-keyboard-ime-input-doesnt-work> or
another one
<https://stackoverflow.com/questions/5419766/how-to-capture-soft-keyboard-input-in-a-view>
.
Post by j***@gmail.com
KR
Jon
Post by j***@gmail.com
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.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/ce85c916-4636-4f78-a8a6-6388862df3eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jon Green
2018-05-29 11:43:32 UTC
Permalink
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?

KR
Jon
Post by Alex Cohn
Post by j***@gmail.com
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.
Sorry, wrong link (I had too many tabs open at a time). Try this one
<https://stackoverflow.com/questions/44664835/android-custom-view-with-type-class-number-keyboard-ime-input-doesnt-work> or
another one
<https://stackoverflow.com/questions/5419766/how-to-capture-soft-keyboard-input-in-a-view>
.
Post by j***@gmail.com
KR
Jon
Post by j***@gmail.com
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.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/e7f72828-2275-4c74-9939-05bd7e1204e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Alex Cohn
2018-05-30 12:23:14 UTC
Permalink
Post by Jon Green
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?
The brute-force way would be to clone and rewrite NativeActivity.java
<https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/app/NativeActivity.java>.
A more elegant approach is to extend android.app.NativeActivity.
NativeContentView and in your C++ code replace NativeActivity.
mNativeContentView (you cannot, unfortunately, do it in Java class that
extends NativeActivity because the field is private). I have never tried
the latter myself, and cannot guarantee that there are no hidden
complications there.

Best of luck,
Alex

KR
Post by Jon Green
Jon
Post by Alex Cohn
Post by j***@gmail.com
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.
Sorry, wrong link (I had too many tabs open at a time). Try this one
<https://stackoverflow.com/questions/44664835/android-custom-view-with-type-class-number-keyboard-ime-input-doesnt-work> or
another one
<https://stackoverflow.com/questions/5419766/how-to-capture-soft-keyboard-input-in-a-view>
.
Post by j***@gmail.com
KR
Jon
Post by j***@gmail.com
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.
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/7337ea22-a007-4d71-b3fc-18359457dc38%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...