Skip to content
This repository was archived by the owner on Jan 12, 2019. It is now read-only.

Android NullPointerException On Activity Destruction  #91

@hvaughan3

Description

@hvaughan3

General information

  • SDK/Library version: 2.1.0
  • Platforms: Android
  • Device OS Version and Device: Android 7 on Nexus 5X

Issue description

The Android OS will destroy activities when the user navigates away from them if the device is low on memory.

If the device is in this mode, when the user navigates to the camera activity from their app, when an attempt to navigate back to the app is made, the app crashes with the following exception:

java.lang.NullPointerException: Attempt to invoke virtual method 'void org.apache.cordova.CallbackContext.success(org.json.JSONObject)' on a null object reference
io.card.cordova.sdk.CardIOCordovaPlugin.onActivityResult (CardIOCordovaPlugin.java:98)
org.apache.cordova.CordovaInterfaceImpl.onActivityResult (CordovaInterfaceImpl.java:159)
org.apache.cordova.CordovaActivity.onActivityResult (CordovaActivity.java:359)
android.app.Activity.dispatchActivityResult (Activity.java:7539)
android.app.ActivityThread.deliverResults (ActivityThread.java:4485)
android.app.ActivityThread.performResumeActivity (ActivityThread.java:3760)
android.app.ActivityThread.handleResumeActivity (ActivityThread.java:3828)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3036)
android.app.ActivityThread.-wrap11 ()
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1696)
android.os.Handler.dispatchMessage (Handler.java:105)
android.os.Looper.loop (Looper.java:164)
android.app.ActivityThread.main (ActivityThread.java:6938)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)

The standard way to fix this is to override onRestoreStateForActivityResult in the Android Activity.

Steps to reproduce:

  1. Open Developer Options on Android device
  2. Enable the Don't keep activities setting
  3. Click button in your app to initiate the camera intent
  4. Take image of credit card
  5. When the system attempt to navigate back to the app, a crash occurs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions