onKeyUpPanel上的空指针?

时间:2015-01-25 13:49:41

标签: android nullpointerexception

我刚刚向我报告了以下崩溃,我甚至不知道如果有什么办法可以解决这个问题。报告的Android版本是4.1,该设备是LG Optimus G.任何关于我能做什么的想法?请注意,我的代码没有任何一行,它是所有内部Android内容,我甚至不确定它是如何报告给我的......

java.lang.NullPointerException
at com.android.internal.policy.impl.PhoneWindow.onKeyUpPanel(PhoneWindow.java:986)
at com.android.internal.policy.impl.PhoneWindow.onKeyUp(PhoneWindow.java:1687)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2098)
at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3621)
at android.view.ViewRootImpl.handleImeFinishedEvent(ViewRootImpl.java:3591)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:2834)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4905)
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)

1 个答案:

答案 0 :(得分:5)

这似乎是一个众所周知的LG问题。要解决add the following code,这将解决LG错误:

@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);
}