NullPointerException related to ActionBar
alexblack opened this issue · comments
One of my users with a Samsung Galaxy Nexus with android 4.1.1 experienced this:
java.lang.NullPointerException
at com.ipaulpro.afilechooser.FileChooserActivity.boolean onCreateOptionsMenu(android.view.Menu)(ProGuard:125)
at android.app.Activity.onCreatePanelMenu(Activity.java:2503)
at android.support.v4.app.FragmentActivity.boolean onCreatePanelMenu(int,android.view.Menu)(ProGuard:275)
at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:393)
at com.android.internal.policy.impl.PhoneWindow.onKeyDownPanel(PhoneWindow.java:767)
at com.android.internal.policy.impl.PhoneWindow.onKeyDown(PhoneWindow.java:1432)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1826)
at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3733)
at android.view.ViewRootImpl.handleImeFinishedEvent(ViewRootImpl.java:3703)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:2933)
at android.os.Handler.dispatchMessage(Handler.java:119)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4873)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:528)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Same crash, tested on
Huawei Ascend P1 (U9200)
Android 4.0.3 (15 - ICE_CREAM_SANDWICH_MR1)
Same crash issue in following devices
- Huawei Ascend P1 (U9200) [[ Android 4.0.3 (15 - ICE_CREAM_SANDWICH_MR1) ]]
- Huawei Ascend Y530 (Y530-U00) [[ Android 4.3 (18 - JELLYBEAN) ]]
- Samsung Galaxy Note 3 (SM-N9005) [[ Android 5.0 (21 - LOLLIPOP) ]]
All these devices have 1 thing in common that is Hardware Menu Button
I am successfully able to resolve this issue by commenting/deleting following code in FileChooserActivity.jva
Line52 :
private static final boolean HAS_ACTIONBAR = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
Line115-116 :
if (HAS_ACTIONBAR)
invalidateOptionsMenu();
Line119-130 :
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (HAS_ACTIONBAR) {
boolean hasBackStack = mFragmentManager.getBackStackEntryCount() > 0;
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(hasBackStack);
actionBar.setHomeButtonEnabled(hasBackStack);
}
return true;
}