I'm getting crash reports from users with Samsung Devices (Galaxy Note 10.1 2014 Edition (lt03wifi), Galaxy Note 10.1 2014 Edition (lt03lte), Galaxy Note3 (hlte), Galaxy Note3 Neo (hl3g) and others), all running Android 5.1. When the user presses the physical menu key within my app, the exception below is thrown. Other devices open the menu just fine and display it correctly.
android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.Resources.getValue(Resources.java:2452)
at android.content.res.Resources.getDrawable(Resources.java:1947)
at android.content.Context.getDrawable(Context.java:409)
at com.android.internal.policy.impl.PhoneWindow.openPanel(PhoneWindow.java:810)
at com.android.internal.policy.impl.PhoneWindow.onKeyUpPanel(PhoneWindow.java:1092)
at com.android.internal.policy.impl.PhoneWindow.onKeyUp(PhoneWindow.java:2179)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2625)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4881)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4836)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4300)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4353)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4319)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4445)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4327)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4502)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4300)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4353)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4319)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4327)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4300)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4353)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4319)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4478)
at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:4720)
at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2811)
at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:2403)
at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:2394)
at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2788)
at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:143)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:6873)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
How can this behaviour be fixed?
My Activity onCreateOptionsMenu:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_develop, menu);
StyleApp.styleMenu(menu,this);
return true;
}
The styleMenu function:
public static void styleMenu(Menu menu,Context c) {
ColorFilter colorFilter = getColorFilter(c);
for(int i=0;i<menu.size();i++){
MenuItem item=menu.getItem(i);
Drawable icon=item.getIcon();
icon.setColorFilter(colorFilter);
}
}