Reflection NullPointerException

madru

Active Member
Licensed User
Longtime User
Hi,

I try to trap a key with the reflection lib and start another Activity as Klaus mentioned in his response (http://www.b4x.com/forum/basic4andr...8-bitmaps-across-title-below-3.html#post98470) but unfortunately I does'd work as expected.

I always get this error:

java.lang.NullPointerException
at anywheresoftware.b4a.agraham.reflection.Reflection$6.onKey(Reflection.java:1039)
at android.view.View.dispatchKeyEvent(View.java:3850)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:789)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1905)
at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1139)
at android.app.Activity.dispatchKeyEvent(Activity.java:2254)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1881)
at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2563)
at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2538)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1870)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
at dalvik.system.NativeStart.main(Native Method)

any ideas ? maybe the Lib is wrongly used ?

THX

M
 

Attachments

  • reflection_test.zip
    6.1 KB · Views: 169

madru

Active Member
Licensed User
Longtime User
…little update, it works up to API8 and fails on all newer versions (>= API10)

can somebody please have a look?

THX
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Try the new version 2.0 of the Reflection library I have just posted.

It looks like later versions of Android seem to raise an OnKey event twice, rather than once, when the Back key (and maybe other keys) keys is pressed. Unfortunately the second event arises when the Activity is closed and this caused a null pointer exception in the Reflection library code.
 
Upvote 0
Top