Note that there are some explanatory texts on larger screens.

plurals
  1. POCrash when closing soft keyboard while using native activity
    primarykey
    data
    text
    <p>We are developing an indie game for android and would like the user to choose his nickname. We have chosen to use the Native Activity that is provided by the NDK as that seemed to be the easiest way to go.</p> <p>The first problem we've encountered with the keyboard was that the function ANativeActivity_showSoftInput() seems to do nothing at all (as described e.g. <a href="https://stackoverflow.com/questions/5864790/how-to-show-the-soft-keyboard-on-native-activity">here</a>), so we bring up the keyboard using JNI calls to function:</p> <pre><code>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); } </code></pre> <p>This works fine for bringing up the keyboard, and works fine on some devices all together. But on other devices (e.g. Nexus 7), when the user tries to close the keyboard by hitting the "hide keyboard" button the application freezes with this debug output:</p> <pre><code>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 </code></pre> <p>And then the user is presented with a dialog box saying:</p> <pre><code>Project isn't responding. Do you want to close it? [Wait]/[OK] </code></pre> <p>Is there something we are doing obviously wrong? Or might this be a bug? Issues like <a href="https://code.google.com/p/android/issues/detail?id=35991" rel="nofollow noreferrer">this one</a> seem to suggest keyboard functionality has never been properly implemented in the native glue.</p> <p>On a side note, we havent tested on many devices yet, but the ones where it doesn't crash are ones with an older android OS. Also, on those where it does crash, when the keyboard appears, it changes the <em>back</em> button from one that looks like this <img src="https://i.stack.imgur.com/8eWJb.png" alt="backward arrow shaped button"> to one that looks like this <img src="https://i.stack.imgur.com/7fjK3.png" alt="V shaped button">. Perhaps that corresponds to a different input event that wasn't accounted for when they first developed the native glue? I'm just guessing .</p> <p>Anyway, if someone got soft keyboard working while using native activity, please let us know how you've done it.</p> <p>Cheers</p> <p><strong>UPDATE</strong></p> <p>It has been reported as a bug in Android <a href="https://code.google.com/p/android/issues/detail?id=43817&amp;thanks=43817&amp;ts=1359632204" rel="nofollow noreferrer">here</a>, we would still be happy to hear about workarounds though. If you are also affected by it, you might want to cast a vote on that issue (by pressing the star).</p>
    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.
 

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