java.lang.NullPointerException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Starting an activity and getting its result is fundamental to Android development. Hyperloop does not provide a way to do this...at least to my knowledge. I worked with several folks on TiSlack and no one seems to have a working solution. Here was the best attempt using what is available in HyperLoop: {code} var Activity = require('android.app.Activity'); var Intent = Alloy.require('android.content.Intent'); var CardIOActivity = Alloy.require('io.card.payment.CardIOActivity'); var MyActivity = Activity.extend({ onActivityResult: function(requestCode, resultCode, data) { console.log('!!!!!!onActivityResult'); } }); //Cast the current activity to your overridden native one var windowActivity = new MyActivity(window.getActivity()); var scanIntent = new Intent(windowActivity, CardIOActivity.class); windowActivity.startActivityForResult(scanIntent, 100); //Fails {code} Here is the error that is thrown: {code} [ERROR] : HyperloopProxy: (main) [6645,21912] Exception thrown during invocation of method: public void Activity_Proxy.startActivityForResult(android.content.Intent,int), args: [Intent { cmp=/io.card.payment.CardIOActivity (has extras) }, 100] [ERROR] : HyperloopProxy: java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.ActivityThread$ApplicationThread android.app.ActivityThread.getApplicationThread()' on a null object reference [ERROR] : HyperloopProxy: at android.app.Activity.startActivityForResult(Activity.java:4026) [ERROR] : HyperloopProxy: at Activity_Proxy.super$startActivityForResult$void(Activity_Proxy.generated) [ERROR] : HyperloopProxy: at java.lang.reflect.Method.invoke(Native Method) [ERROR] : HyperloopProxy: at java.lang.reflect.Method.invoke(Method.java:372) [ERROR] : HyperloopProxy: at com.android.dx.stock.ProxyBuilder.callSuper(ProxyBuilder.java:546) [ERROR] : HyperloopProxy: at hyperloop.DynamicSubclassInvocationHandler.invoke(DynamicSubclassInvocationHandler.java:33) [ERROR] : HyperloopProxy: at Activity_Proxy.startActivityForResult(Activity_Proxy.generated) [ERROR] : HyperloopProxy: at android.app.Activity.startActivityForResult(Activity.java:3973) [ERROR] : HyperloopProxy: at Activity_Proxy.super$startActivityForResult$void(Activity_Proxy.generated) [ERROR] : HyperloopProxy: at java.lang.reflect.Method.invoke(Native Method) [ERROR] : HyperloopProxy: at java.lang.reflect.Method.invoke(Method.java:372) [ERROR] : HyperloopProxy: at com.android.dx.stock.ProxyBuilder.callSuper(ProxyBuilder.java:546) [ERROR] : HyperloopProxy: at hyperloop.DynamicSubclassInvocationHandler.invoke(DynamicSubclassInvocationHandler.java:33) [ERROR] : HyperloopProxy: at Activity_Proxy.startActivityForResult(Activity_Proxy.generated) [ERROR] : HyperloopProxy: at java.lang.reflect.Method.invoke(Native Method) [ERROR] : HyperloopProxy: at java.lang.reflect.Method.invoke(Method.java:372) [ERROR] : HyperloopProxy: at hyperloop.BaseProxy.invokeMethod(BaseProxy.java:145) [ERROR] : HyperloopProxy: at hyperloop.InstanceProxy.invokeMethod(InstanceProxy.java:183) [ERROR] : HyperloopProxy: at hyperloop.BaseProxy.callNativeFunction(BaseProxy.java:127) [ERROR] : HyperloopProxy: at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method) [ERROR] : HyperloopProxy: at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62) [ERROR] : HyperloopProxy: at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:918) [ERROR] : HyperloopProxy: at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1141) [ERROR] : HyperloopProxy: at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:357) [ERROR] : HyperloopProxy: at android.os.Handler.dispatchMessage(Handler.java:98) [ERROR] : HyperloopProxy: at android.os.Looper.loop(Looper.java:145) [ERROR] : HyperloopProxy: at android.app.ActivityThread.main(ActivityThread.java:6843) [ERROR] : HyperloopProxy: at java.lang.reflect.Method.invoke(Native Method) [ERROR] : HyperloopProxy: at java.lang.reflect.Method.invoke(Method.java:372) [ERROR] : HyperloopProxy: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) [ERROR] : HyperloopProxy: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) {code}
    via by Brian Knorr,
  • StartActivity() crashes the application
    via by Unknown author,
  • Error starting Activity from a Class on Android
    via Stack Overflow by Maya
    ,
    • java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.ActivityThread$ApplicationThread android.app.ActivityThread.getApplicationThread()' on a null object reference at android.app.Activity.startActivityForResult(Activity.java:4026) at Activity_Proxy.super$startActivityForResult$void(Activity_Proxy.generated) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.dx.stock.ProxyBuilder.callSuper(ProxyBuilder.java:546) at hyperloop.DynamicSubclassInvocationHandler.invoke(DynamicSubclassInvocationHandler.java:33) at Activity_Proxy.startActivityForResult(Activity_Proxy.generated) at android.app.Activity.startActivityForResult(Activity.java:3973) at Activity_Proxy.super$startActivityForResult$void(Activity_Proxy.generated) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.dx.stock.ProxyBuilder.callSuper(ProxyBuilder.java:546) at hyperloop.DynamicSubclassInvocationHandler.invoke(DynamicSubclassInvocationHandler.java:33) at Activity_Proxy.startActivityForResult(Activity_Proxy.generated) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at hyperloop.BaseProxy.invokeMethod(BaseProxy.java:145) at hyperloop.InstanceProxy.invokeMethod(InstanceProxy.java:183) at hyperloop.BaseProxy.callNativeFunction(BaseProxy.java:127) at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method) at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62) at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:918) at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1141) at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:357) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:6843) 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)

    Users with the same issue

    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    filpgamefilpgame
    5 times, last one,
    16 more bugmates