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. This finishes B and C and opens A which in the manifest is set as a singletask.
从C回到A,你打开菜单,然后点击主页。这样就完成了B和C并打开了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();
}
1 个解决方案
#1
0
You do not need singleTask
, in all likelihood. In C, when you call startActivity()
, pass FLAG_ACTIVITY_CLEAR_TOP|FLAG_ACTIVITY_SINGLE_TOP
as the Intent
flags. That will finish C and B en route to starting A.
你很可能不需要singleTask。在C中,当您调用startActivity()时,将FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_SINGLE_TOP作为Intent标志传递。这将完成C和B在开始A的途中。
#1
0
You do not need singleTask
, in all likelihood. In C, when you call startActivity()
, pass FLAG_ACTIVITY_CLEAR_TOP|FLAG_ACTIVITY_SINGLE_TOP
as the Intent
flags. That will finish C and B en route to starting A.
你很可能不需要singleTask。在C中,当您调用startActivity()时,将FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_SINGLE_TOP作为Intent标志传递。这将完成C和B在开始A的途中。