when i am browsing in my app i get sometimes this error. I am not sure this error comes randomly and i can’t find out why. The Log doesn’t show anything specific to my application?
I hope someone could give me a tip or a hint why this error occoures. (The last time it came when i tried to open a popup, a Quickaction Dialog, after occouring a second time with the same Quickaction Dialog it worked again after i tried it a 3rd time. And now it works all the time, again?)
08-01 11:09:15.980: ERROR/AndroidRuntime(9579): FATAL EXCEPTION: main
08-01 11:09:15.980: ERROR/AndroidRuntime(9579): java.lang.NullPointerException
08-01 11:09:15.980: ERROR/AndroidRuntime(9579): at android.widget.PopupWindow$PopupViewContainer.dispatchKeyEvent(PopupWindow.java:1445)
08-01 11:09:15.980: ERROR/AndroidRuntime(9579): at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2664)
08-01 11:09:15.980: ERROR/AndroidRuntime(9579): at android.view.ViewRoot.deliverKeyEvent(ViewRoot.java:2629)
08-01 11:09:15.980: ERROR/AndroidRuntime(9579): at android.view.ViewRoot.handleMessage(ViewRoot.java:1935)
08-01 11:09:15.980: ERROR/AndroidRuntime(9579): at android.os.Handler.dispatchMessage(Handler.java:99)
08-01 11:09:15.980: ERROR/AndroidRuntime(9579): at android.os.Looper.loop(Looper.java:143)
08-01 11:09:15.980: ERROR/AndroidRuntime(9579): at android.app.ActivityThread.main(ActivityThread.java:4196)
08-01 11:09:15.980: ERROR/AndroidRuntime(9579): at java.lang.reflect.Method.invokeNative(Native Method)
08-01 11:09:15.980: ERROR/AndroidRuntime(9579): at java.lang.reflect.Method.invoke(Method.java:507)
08-01 11:09:15.980: ERROR/AndroidRuntime(9579): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-01 11:09:15.980: ERROR/AndroidRuntime(9579): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-01 11:09:15.980: ERROR/AndroidRuntime(9579): at dalvik.system.NativeStart.main(Native Method)
Here some more details:
QuickAction qa = QuickactionBuilder.showSaveForgetQuickaction();
qa.setOnActionItemClickListener(new QuickAction.OnActionItemClickListener() {
@Override
public void onItemClick(int pos) {
if (pos == 0) { // SAVE
Toast.makeText(ctxHolder.getCtx(), "TODO SAVE", Toast.LENGTH_SHORT).show();
} else if (pos == 1) { // REJECT
Toast.makeText(ctxHolder.getCtx(), "REJECTED", Toast.LENGTH_SHORT).show();
} else { // CANCEL
Toast.makeText(ctxHolder.getCtx(), "CANCEL", Toast.LENGTH_SHORT).show();
}
}
});
qa.show(v);
THe QuickactionBuilder only creates the QuickAction Dialog for me.
That’s as simple as:
(Only to show the basics of that method)
QuickAction qa = new QuickAction
ActionItem ai = new ActionItem()
// some setters ...
qa.add(ai)
return qa;
I had the same problem with QuickAction
i received crashes from users although i couldn’t reproduce them on my devices
so if anyone still needs the solution i’d be glad to share it
the idea is to avoid of using PopupViewContainer in PopupWindow because the crash bug is in its dispatchKeyEvent(KeyEvent event) method. The only way i could do that is to keep backgroundDrawable == null. Then you have to handle outside touches and Back button yourself.
PopupWindows Class:
Do not set any drawable here:
And everything next is classic
CustomRelativeLayout:
popup_vertical.xml and popup_horizontal.xml:
just use com.your.package.CustomRelativeLayout instead of top level RelativeLayout
Hope this will help