Search code examples
androidnullpointerexceptionandroid-input-methoduncaught-exceptionandroid-anr-dialog

Samsung: On power off InputMethodService is crashed (NullPointerException)


Unable to detect the issue.This issue is specific to Samsung Device.

Another thing that i got in my log :

"Unexpected null in startExtractingText : mExtractedText = null, input connection = com.android.internal.view.InputConnectionWrapper"


11-23 15:44:06.463 21778-21778/? W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.inputmethodservice.InputMethodService.forceExtractEditTextClose()' on a null object reference
11-23 15:44:06.463 21778-21778/? W/System.err:     at android.inputmethodservice.ExtractEditText.onScreenStateChanged(ExtractEditText.java:246)
11-23 15:44:06.463 21778-21778/? W/System.err:     at android.view.View.dispatchScreenStateChanged(View.java:15375)
11-23 15:44:06.463 21778-21778/? W/System.err:     at android.view.ViewGroup.dispatchScreenStateChanged(ViewGroup.java:3164)
11-23 15:44:06.463 21778-21778/? W/System.err:     at android.view.ViewGroup.dispatchScreenStateChanged(ViewGroup.java:3164)
11-23 15:44:06.463 21778-21778/? W/System.err:     at android.view.ViewGroup.dispatchScreenStateChanged(ViewGroup.java:3164)
11-23 15:44:06.463 21778-21778/? W/System.err:     at android.view.ViewGroup.dispatchScreenStateChanged(ViewGroup.java:3164)
11-23 15:44:06.463 21778-21778/? W/System.err:     at android.view.ViewGroup.dispatchScreenStateChanged(ViewGroup.java:3164)
11-23 15:44:06.463 21778-21778/? W/System.err:     at android.view.ViewGroup.dispatchScreenStateChanged(ViewGroup.java:3164)
11-23 15:44:06.463 21778-21778/? W/System.err:     at android.view.ViewGroup.dispatchScreenStateChanged(ViewGroup.java:3164)
11-23 15:44:06.463 21778-21778/? W/System.err:     at android.view.ViewGroup.dispatchScreenStateChanged(ViewGroup.java:3164)
11-23 15:44:06.463 21778-21778/? W/System.err:     at android.view.ViewRootImpl$1.onDisplayChanged(ViewRootImpl.java:1171)
11-23 15:44:06.463 21778-21778/? W/System.err:     at android.hardware.display.DisplayManagerGlobal$DisplayListenerDelegate.handleMessage(DisplayManagerGlobal.java:724)
11-23 15:44:06.463 21778-21778/? W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
11-23 15:44:06.463 21778-21778/? W/System.err:     at android.os.Looper.loop(Looper.java:158)
11-23 15:44:06.463 21778-21778/? W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:7225)
11-23 15:44:06.463 21778-21778/? W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
11-23 15:44:06.463 21778-21778/? W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
11-23 15:44:06.463 21778-21778/? W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

Solution

  • I have resolved this issue by own. In my case , I was adding my custom view on overrided method setExtractView(View view). But I was not removing views first.

    Let me explain :

    @Override
    public void setExtractView(View view) {
      // You have to do this if you are not doing so
      view.removeAllViews() ; // This is the line 
      view.addView(yourView) ; // Here you can put your own  Custom view 
      super.setExtractView(view);
    } 
    

    This is working for me. I hope this will help you when you will get the issue like

    "Unexpected null in startExtractingText : mExtractedText = null, input connection = com.android.internal.view.InputConnectionWrapper"