android app crashes if keyboard was shown

Posted by Jaume on Stack Overflow See other posts from Stack Overflow or by Jaume
Published on 2012-07-07T16:44:34Z Indexed on 2012/07/11 9:15 UTC
Read the original article Hit count: 245

Filed under:
|

I have an activity that I force keyboard to appears using,

InputMethodManager inputMethodManager=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);

keyboard appears properly and also obscured when needed. Problem is when I finish the activity, app crashes. If the activity never shows keyboard or shows it without start editing text, it is finished with no errors but if you just write one single character or more, app will crash. How to solve it? thank you.

method used to finish activity,

    boto_back.setOnClickListener(new OnClickListener() 
            {
                @Override
                public void onClick(View arg0) 
                {
                    InputMethodManager inputMethodManager=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
                    inputMethodManager.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);


                    finish();
                }
            });
 @Override
      public void onDestroy() 
      {
        if (adMob != null) 
        {
          // Destroy the AdView.
          adMob.destroy();
        }

        super.onDestroy();
      }

logcat,

07-07 19:04:25.191: E/AndroidRuntime(8443): FATAL EXCEPTION: main
07-07 19:04:25.191: E/AndroidRuntime(8443): java.lang.RuntimeException: Unable to destroy activity {com.xxxx.xxxx/com.xxxx.projecte1.TabBar_iOSActivity}: java.lang.RuntimeException: Unable to destroy activity {com.xxxx.xxxx/com.xxxx.projecte1.webPush}: java.lang.NullPointerException
07-07 19:04:25.191: E/AndroidRuntime(8443):     at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2693)
07-07 19:04:25.191: E/AndroidRuntime(8443):     at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:2711)
07-07 19:04:25.191: E/AndroidRuntime(8443):     at android.app.ActivityThread.access$2100(ActivityThread.java:121)
07-07 19:04:25.191: E/AndroidRuntime(8443):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:976)
07-07 19:04:25.191: E/AndroidRuntime(8443):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-07 19:04:25.191: E/AndroidRuntime(8443):     at android.os.Looper.loop(Looper.java:130)
07-07 19:04:25.191: E/AndroidRuntime(8443):     at android.app.ActivityThread.main(ActivityThread.java:3701)
07-07 19:04:25.191: E/AndroidRuntime(8443):     at java.lang.reflect.Method.invokeNative(Native Method)
07-07 19:04:25.191: E/AndroidRuntime(8443):     at java.lang.reflect.Method.invoke(Method.java:507)
07-07 19:04:25.191: E/AndroidRuntime(8443):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
07-07 19:04:25.191: E/AndroidRuntime(8443):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
07-07 19:04:25.191: E/AndroidRuntime(8443):     at dalvik.system.NativeStart.main(Native Method)
07-07 19:04:25.191: E/AndroidRuntime(8443): Caused by: java.lang.RuntimeException: Unable to destroy activity {com.xxxx.xxxx/com.xxxx.projecte1.webPush}: java.lang.NullPointerException
07-07 19:04:25.191: E/AndroidRuntime(8443):     at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2693)
07-07 19:04:25.191: E/AndroidRuntime(8443):     at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2603)
07-07 19:04:25.191: E/AndroidRuntime(8443):     at android.app.LocalActivityManager.dispatchDestroy(LocalActivityManager.java:622)
07-07 19:04:25.191: E/AndroidRuntime(8443):     at android.app.ActivityGroup.onDestroy(ActivityGroup.java:85)
07-07 19:04:25.191: E/AndroidRuntime(8443):     at com.xxxx.projecte1.TabBar_iOSActivity.onDestroy(TabBar_iOSActivity.java:417)
07-07 19:04:25.191: E/AndroidRuntime(8443):     at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2680)
07-07 19:04:25.191: E/AndroidRuntime(8443):     ... 11 more

© Stack Overflow or respective owner

Related posts about java

Related posts about android