Activity is closed after onActivityResult is called

做~自己de王妃 提交于 2020-02-06 05:43:09

问题


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;
    }
}

回答1:


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



来源:https://stackoverflow.com/questions/30214329/activity-is-closed-after-onactivityresult-is-called

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!