[英]New Intent wont start first time
I have 3 intents A->B->C 我有3个意图A-> B-> C
from C to get back to A you bring up the menu and click home. 从C返回A,您将弹出菜单并单击home。 This finishes B and C and opens A which in the manifest is set as a singletask. 这将完成B和C并打开A,该A在清单中被设置为单个任务。
This all works perfectly, but when I try to open B from A again I have to click twice on the button that starts B. Whereas when the app first opens I have to click only the once to open B 这一切都可以正常工作,但是当我尝试再次从A打开B时,我必须单击启动B的按钮两次。而当应用首次打开时,我只需要单击一次即可打开B。
Why could this be like this? 为什么会这样呢?
I think I know why. 我想我知道为什么。 I think B is not finishing when I go from C to A. This is the code running on C 我认为从C到A时B尚未完成。这是在C上运行的代码
Intent Intent = new Intent(this, com.home.test.Home.class);
this.setResult(1, Intent);
startActivity(Intent);
this.finish();
And it should trigger this on B if I am correct 如果我是正确的,它应该在B上触发
public void onActivityResult(int requestCode, int resultCode, Intent data) {
this.finish();
}
You do not need singleTask
, in all likelihood. 您完全不需要singleTask
。 In C, when you call startActivity()
, pass FLAG_ACTIVITY_CLEAR_TOP|FLAG_ACTIVITY_SINGLE_TOP
as the Intent
flags. 在C中,当您调用startActivity()
,传递FLAG_ACTIVITY_CLEAR_TOP|FLAG_ACTIVITY_SINGLE_TOP
作为Intent
标志。 That will finish C and B en route to starting A. 这样就可以在开始A的途中完成C和B。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.