We are developing an indie game for Android and would like the user to choose their nickname. We decided to use the Native Activity, which is provided by the NDK, as this seemed to be the easiest way.
The first problem we encountered with the keyboard was that the ANativeActivity_showSoftInput () function seems to be doing nothing (as described, for example here ), so we bring the keyboard using JNI calls to work:
static void showKeyboard(Activity activity) {
String s = Context.INPUT_METHOD_SERVICE;
InputMethodManager m = (InputMethodManager)activity.getSystemService(s);
View w = activity.getWindow().getDecorView();
m.showSoftInput(w, 0);
}
This is great for creating keyboards and works great on some devices. But on other devices (for example, Nexus 7), when the user tries to close the keyboard by clicking the "Hide Keyboard" button, the application freezes with this debug output:
I/InputDispatcher( 453): Application is not responding: AppWindowToken{429b54a8 token=Token{42661288 ActivityRecord{41bb0b00 u0 com.example.project/android.app.NativeActivity}}} - Window{420d6138 u0 com.example.project/android.app.NativeActivity}. It has been 5006.7ms since event, 5005.6ms since wait started. Reason: Waiting because the focused window has not finished processing the input events that were previously delivered to it.
I/WindowManager( 453): Input event dispatching timed out sending to com.example.project/android.app.NativeActivity
Then the user is presented with a dialog box with the message:
Project isn't responding. Do you want to close it? [Wait]/[OK]
Is there something we are clearly doing wrong? Or could it be a mistake? Problems like this seem to say that keyboard functionality has never been properly implemented in native bite.
, , , , - , Android. , , , , ,
, , :
. , , , ? .
, - , , , .
UPDATE
Android , . , ( ).