Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

App crashes when main activity is closed on Android #344

Closed
jariztia opened this issue Oct 20, 2016 · 1 comment
Closed

App crashes when main activity is closed on Android #344

jariztia opened this issue Oct 20, 2016 · 1 comment
Milestone

Comments

@jariztia
Copy link

Expected Behaviour

When a code is scanned it should return to the app with the right callbackContext. This can be resolved by overriding the onRestoreStateForActivityResult method on the plugin and set the callbackContext object. This way the app won't crash and the result will be available on the on resume event. I will make a pull-request with this solution.

import android.os.Bundle;

public void onRestoreStateForActivityResult(Bundle state, CallbackContext callbackContext) {
    this.callbackContext = callbackContext;
}

Actual Behaviour

If the phone settings are set to kill background tasks or there is any other cleaner that kills the main app activity, then the plugins returns to the app with a null object and crashes the app.

Reproduce Scenario (including but not limited to)

Any app with the scanner in Android.

Steps to Reproduce

In any phone, in developer options set "Don't keep activities" to true. Now when scanning a code you won't be able to get the result in the app once it opens again.

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

Any Android, tested on 5.0.

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

Any Vendor, tested on an LG G3.

Cordova CLI version and cordova platform version

Any version of cordova, tested on 4.4.2.

Plugin version

cordova plugin version | grep phonegap-plugin-barcodescanner 6.0.1
@lock
Copy link

lock bot commented Jun 8, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants