Denis Vitez
Denis Vitez

Reputation: 648

Activity is closed after onActivityResult is called

Activity Explanation:

Activity_A ... nfc activity that gets started when tag is read

Activity_B ... activity to capture user signature

Hi, my problem goes like that: I have Activity_A and in that activity I call Activity_B with startActivityForResult() method. I then do some work in Activity_B and close it. After that method onActivityResult() is called in my Activity_A. I handle the returned data and all is great, but Activity_A is no longer visible.

If I close Activity_B with back button, then Activity_A is still visible. (onActivityResult() doesn't get called).

I would like my Activity_A to stay active and visible when I return from Activity_B.

I have tested on 2 devices both running Kitkat (4.4.2 and 4.4.4). I can't test it on emulator, since Activity_A is NFC activity.

onActivityResult code:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Log.d(TAG, "onActivityResult is called");
    switch(requestCode) {
        case SIGNATURE_ACTIVITY:
            if (resultCode == RESULT_OK) {
                Bundle bundle = data.getExtras();
                String signatureFile = data.getStringExtra("SIGNATURE_FILE");
                if(signatureFile !=null ) {
                    this.showToastMessage("Signature captured!");
                    presenter.loadSignatureImage(signatureFile);
                } else {
                    this.showToastMessage("Signature filename not returned!");
                }
            }
            break;
    }
}

Upvotes: 2

Views: 1545

Answers (1)

Dev Tamil
Dev Tamil

Reputation: 649

Make sure you are not using intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
before starting the current activity.

Upvotes: 2

Related Questions