Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NullPointerException (@PhoneWindow:onKeyUpPanel:1002) {main}

Tags:

java

android

I get strange exceptions in my analytics lately.

java.lang.NullPointerException
at com.android.internal.policy.impl.PhoneWindow.onKeyUpPanel(PhoneWindow.java:1002)
at com.android.internal.policy.impl.PhoneWindow.onKeyUp(PhoneWindow.java:1703)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2114)
at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3626)
at android.view.ViewRootImpl.handleImeFinishedEvent(ViewRootImpl.java:3596)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:2839)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4904)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)

I am missing a lead on what I can do to prevent this.

like image 900
ligi Avatar asked Nov 09 '14 20:11

ligi


1 Answers

Until LG fixes this issue (which could be months, depending on how long it takes them to release new firmware), the following workaround worked for me. Just add the following code to your Activity class:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_MENU && "LGE".equalsIgnoreCase(Build.BRAND)) {
       return true;
   }
   return super.onKeyDown(keyCode, event);
}

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_MENU && "LGE".equalsIgnoreCase(Build.BRAND)) {
       openOptionsMenu();
       return true;
   }
   return super.onKeyUp(keyCode, event);
}
like image 50
Alex Lockwood Avatar answered Sep 17 '22 14:09

Alex Lockwood