在调用onActivityResult之后,活动被关闭 [英] Activity is closed after onActivityResult is called
问题描述
活动说明:
Activity_A ...读取标签时开始的nfc活动
Activity_A ... nfc activity that gets started when tag is read
Activity_B ...捕获用户签名的活动
Activity_B ... activity to capture user signature
我的问题是这样的:
我有Activity_A,在该活动中,我使用startActivityForResult()
方法调用Activity_B.然后,我在Activity_B中进行一些工作并将其关闭.之后,在我的Activity_A中调用onActivityResult()
方法.我处理了返回的数据,一切都很好,但是Activity_A不再可见.
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.
如果我使用后退"按钮关闭Activity_B,则Activity_A仍然可见. (onActivityResult()
不会被调用).
If I close Activity_B with back button, then Activity_A is still visible. (onActivityResult()
doesn't get called).
当我从Activity_B返回时,我希望我的Activity_A保持活跃并可见.
I would like my Activity_A to stay active and visible when I return from Activity_B.
我已经在运行Kitkat的2台设备(4.4.2和4.4.4)上进行了测试. 由于Activity_A是NFC活动,因此我无法在模拟器上对其进行测试.
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代码:
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;
}
}
推荐答案
确保您没有使用intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
在开始当前活动之前.
Make sure you are not using intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
before starting the current activity.
这篇关于在调用onActivityResult之后,活动被关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!