Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have got exactly the same problem. No way to show the Keyboard using this API.</p> <p>The only way I found was to use JNI but of course I am not satisfied with that solution:</p> <pre><code>android_app* mApplication; ... void displayKeyboard(bool pShow) { // Attaches the current thread to the JVM. jint lResult; jint lFlags = 0; JavaVM* lJavaVM = mApplication-&gt;activity-&gt;vm; JNIEnv* lJNIEnv = mApplication-&gt;activity-&gt;env; JavaVMAttachArgs lJavaVMAttachArgs; lJavaVMAttachArgs.version = JNI_VERSION_1_6; lJavaVMAttachArgs.name = "NativeThread"; lJavaVMAttachArgs.group = NULL; lResult=lJavaVM-&gt;AttachCurrentThread(&amp;lJNIEnv, &amp;lJavaVMAttachArgs); if (lResult == JNI_ERR) { return; } // Retrieves NativeActivity. jobject lNativeActivity = mApplication-&gt;activity-&gt;clazz; jclass ClassNativeActivity = lJNIEnv-&gt;GetObjectClass(lNativeActivity); // Retrieves Context.INPUT_METHOD_SERVICE. jclass ClassContext = lJNIEnv-&gt;FindClass("android/content/Context"); jfieldID FieldINPUT_METHOD_SERVICE = lJNIEnv-&gt;GetStaticFieldID(ClassContext, "INPUT_METHOD_SERVICE", "Ljava/lang/String;"); jobject INPUT_METHOD_SERVICE = lJNIEnv-&gt;GetStaticObjectField(ClassContext, FieldINPUT_METHOD_SERVICE); jniCheck(INPUT_METHOD_SERVICE); // Runs getSystemService(Context.INPUT_METHOD_SERVICE). jclass ClassInputMethodManager = lJNIEnv-&gt;FindClass( "android/view/inputmethod/InputMethodManager"); jmethodID MethodGetSystemService = lJNIEnv-&gt;GetMethodID( ClassNativeActivity, "getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;"); jobject lInputMethodManager = lJNIEnv-&gt;CallObjectMethod( lNativeActivity, MethodGetSystemService, INPUT_METHOD_SERVICE); // Runs getWindow().getDecorView(). jmethodID MethodGetWindow = lJNIEnv-&gt;GetMethodID( ClassNativeActivity, "getWindow", "()Landroid/view/Window;"); jobject lWindow = lJNIEnv-&gt;CallObjectMethod(lNativeActivity, MethodGetWindow); jclass ClassWindow = lJNIEnv-&gt;FindClass( "android/view/Window"); jmethodID MethodGetDecorView = lJNIEnv-&gt;GetMethodID( ClassWindow, "getDecorView", "()Landroid/view/View;"); jobject lDecorView = lJNIEnv-&gt;CallObjectMethod(lWindow, MethodGetDecorView); if (pShow) { // Runs lInputMethodManager.showSoftInput(...). jmethodID MethodShowSoftInput = lJNIEnv-&gt;GetMethodID( ClassInputMethodManager, "showSoftInput", "(Landroid/view/View;I)Z"); jboolean lResult = lJNIEnv-&gt;CallBooleanMethod( lInputMethodManager, MethodShowSoftInput, lDecorView, lFlags); } else { // Runs lWindow.getViewToken() jclass ClassView = lJNIEnv-&gt;FindClass( "android/view/View"); jmethodID MethodGetWindowToken = lJNIEnv-&gt;GetMethodID( ClassView, "getWindowToken", "()Landroid/os/IBinder;"); jobject lBinder = lJNIEnv-&gt;CallObjectMethod(lDecorView, MethodGetWindowToken); // lInputMethodManager.hideSoftInput(...). jmethodID MethodHideSoftInput = lJNIEnv-&gt;GetMethodID( ClassInputMethodManager, "hideSoftInputFromWindow", "(Landroid/os/IBinder;I)Z"); jboolean lRes = lJNIEnv-&gt;CallBooleanMethod( lInputMethodManager, MethodHideSoftInput, lBinder, lFlags); } // Finished with the JVM. lJavaVM-&gt;DetachCurrentThread(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload