java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.ActivityThread$ApplicationThread android.app.ActivityThread.getApplicationThread()' on a null object reference

Appcelerator JIRA | Brian Knorr | 2 months ago
  1. 0

    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}

    Appcelerator JIRA | 2 months ago | Brian Knorr
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.ActivityThread$ApplicationThread android.app.ActivityThread.getApplicationThread()' on a null object reference
  2. 0

    Request facebook permission --NullPointerException

    Stack Overflow | 2 years ago | nithin
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.ActivityThread$ApplicationThread android.app.ActivityThread.getApplicationThread()' on a null object reference
  3. 0

    StartActivity() crashes the application

    Stack Overflow | 2 years ago
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.ActivityThread$ApplicationThread android.app.ActivityThread.getApplicationThread()' on a null object reference
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Execute a method from a class in mainActivity (Android)

    Stack Overflow | 2 years ago
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.ActivityThread$ApplicationThread android.app.ActivityThread.getApplicationThread()' on a null object reference
  6. 0

    Android: Call and execute a Class on the MainActivity Class

    Stack Overflow | 2 years ago
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.ActivityThread$ApplicationThread android.app.ActivityThread.getApplicationThread()' on a null object reference

  1. filpgame 5 times, last 4 weeks ago
  2. Dan Dascalescu 1 times, last 5 months ago
17 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. 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()
  2. Android Platform
    Activity.startActivityForResult
    1. android.app.Activity.startActivityForResult(Activity.java:4026)
    1 frame
  3. Unknown
    Activity_Proxy.super$startActivityForResult$void
    1. Activity_Proxy.super$startActivityForResult$void(Activity_Proxy.generated)
    1 frame
  4. Java RT
    Method.invoke
    1. java.lang.reflect.Method.invoke(Native Method)
    2. java.lang.reflect.Method.invoke(Method.java:372)
    2 frames
  5. com.android.dx
    ProxyBuilder.callSuper
    1. com.android.dx.stock.ProxyBuilder.callSuper(ProxyBuilder.java:546)
    1 frame
  6. hyperloop
    DynamicSubclassInvocationHandler.invoke
    1. hyperloop.DynamicSubclassInvocationHandler.invoke(DynamicSubclassInvocationHandler.java:33)
    1 frame
  7. Unknown
    Activity_Proxy.startActivityForResult
    1. Activity_Proxy.startActivityForResult(Activity_Proxy.generated)
    1 frame
  8. Android Platform
    Activity.startActivityForResult
    1. android.app.Activity.startActivityForResult(Activity.java:3973)
    1 frame
  9. Unknown
    Activity_Proxy.super$startActivityForResult$void
    1. Activity_Proxy.super$startActivityForResult$void(Activity_Proxy.generated)
    1 frame
  10. Java RT
    Method.invoke
    1. java.lang.reflect.Method.invoke(Native Method)
    2. java.lang.reflect.Method.invoke(Method.java:372)
    2 frames
  11. com.android.dx
    ProxyBuilder.callSuper
    1. com.android.dx.stock.ProxyBuilder.callSuper(ProxyBuilder.java:546)
    1 frame
  12. hyperloop
    DynamicSubclassInvocationHandler.invoke
    1. hyperloop.DynamicSubclassInvocationHandler.invoke(DynamicSubclassInvocationHandler.java:33)
    1 frame
  13. Unknown
    Activity_Proxy.startActivityForResult
    1. Activity_Proxy.startActivityForResult(Activity_Proxy.generated)
    1 frame
  14. Java RT
    Method.invoke
    1. java.lang.reflect.Method.invoke(Native Method)
    2. java.lang.reflect.Method.invoke(Method.java:372)
    2 frames
  15. hyperloop
    BaseProxy.callNativeFunction
    1. hyperloop.BaseProxy.invokeMethod(BaseProxy.java:145)
    2. hyperloop.InstanceProxy.invokeMethod(InstanceProxy.java:183)
    3. hyperloop.BaseProxy.callNativeFunction(BaseProxy.java:127)
    3 frames
  16. org.appcelerator.kroll
    KrollProxy.handleMessage
    1. org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
    2. org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62)
    3. org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:918)
    4. org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1141)
    4 frames
  17. org.appcelerator.titanium
    TiViewProxy.handleMessage
    1. org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:357)
    1 frame
  18. Android Platform
    ActivityThread.main
    1. android.os.Handler.dispatchMessage(Handler.java:98)
    2. android.os.Looper.loop(Looper.java:145)
    3. android.app.ActivityThread.main(ActivityThread.java:6843)
    3 frames
  19. Java RT
    Method.invoke
    1. java.lang.reflect.Method.invoke(Native Method)
    2. java.lang.reflect.Method.invoke(Method.java:372)
    2 frames
  20. Android
    ZygoteInit.main
    1. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
    2. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
    2 frames