简体   繁体   中英

Keyboard Hidden crashes on android Lollipop

Does anyone solve the problem with keyboard hidden crash on android 5.0? I've tried on 4.4.2 with the same code but it doesn't happen.

This is my activity settings:

<activity
        android:name=".activity.MainActivity"
        android:configChanges="orientation|screenSize"
        android:hardwareAccelerated="true"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.NoActionBar">

This is the log after freezing

06-17 20:43:57.823 32593-32604/org.mydev.app.debug W/art: Suspending all threads took: 14.210ms
06-17 20:43:59.503 32593-32604/org.mydev.app.debug W/art: Suspending all threads took: 195.356ms
06-17 20:44:02.633 32593-931/org.mydev.app.debug E/UncaughtException: java.lang.NullPointerException: Attempt to read from field 'java.lang.Object maps.W.d$c.c' on a null object reference
                                                                                  at maps.W.d.a(Unknown Source)
                                                                                  at maps.W.d.b(Unknown Source)
                                                                                  at maps.X.J.a(Unknown Source)
                                                                                  at maps.ac.i$d.a(Unknown Source)
                                                                                  at maps.ac.i.a(Unknown Source)
                                                                                  at maps.ac.n.a(Unknown Source)
                                                                                  at maps.X.A.a(Unknown Source)
                                                                                  at maps.X.H.a(Unknown Source)
                                                                                  at maps.X.H.b(Unknown Source)
                                                                                  at maps.X.y$f.f(Unknown Source)
                                                                                  at maps.X.y$f.run(Unknown Source)
06-17 20:44:02.673 32593-32593/org.mydev.app.debug I/Choreographer: Skipped 557 frames!  The application may be doing too much work on its main thread.

Try this.

<activity
        android:windowSoftInputMode="stateHidden"
        android:name=".activity.MainActivity"
        android:configChanges="orientation|screenSize"
        android:hardwareAccelerated="true"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.NoActionBar">

else use this method to hide the Keyboard with respect to EditText.

public static void hideKeyboadOnView(Context context, View view) {
    InputMethodManager inputManager = (InputMethodManager)
            context.getSystemService(Context.INPUT_METHOD_SERVICE);

    inputManager.hideSoftInputFromWindow(
            view.getWindowToken(), 0);

   /* inputManager.hideSoftInputFromWindow(activity.getCurrentFocus()
                    .getWindowToken(),
            InputMethodManager.HIDE_NOT_ALWAYS);*/
}

and pass the edittext view in this method.

I solved this by adding android:windowSoftInputMode="adjustPan". Thank you all for guiding me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM