简体   繁体   English

调用finish()后,ActivityGroup的子活动未完成

[英]Child Activity of ActivityGroup is not finished after finish() is called

I have a program using ActivityGroup. 我有一个使用ActivityGroup的程序。 The class structure is as below: 类结构如下:

Class A extends ActivityGroup {
onCreate(){
}
}

Class B extends A {
onCreate() {
startActivityResult();//launch C
}

onActivityResult(){
...
finish();//finish activity after receive result from C;this line of code does execute in test
...
}
}

Class C extends A {
onCreate(){
...
}
}

B is the entrance for the overall program. B是整个程序的入口。 In B's onCreate() , I use startActivityResult() to launch C; 在B的onCreate() ,我使用startActivityResult()启动C; in C, it will show user a button; 在C中,它将向用户显示一个按钮; after user clicks the button, C will call finish() and setResult(); 用户单击按钮后,C将调用finish()setResult(); then in B's onActivityResult() , I try use the method finish() to exit all of the application. 然后在B的onActivityResult() ,尝试使用finish()方法退出所有应用程序。

The problem is that the screen turns into black after press the button. 问题是按下按钮后屏幕变成黑色。 Then I use hierarchyviewer.bat too see the views; 然后我也使用hierarchyviewer.bat也可以看到视图; to my suprise, there are a view with id R.id.content and another root view without id. 令我惊讶的是,有一个ID为R.id.content的视图和另一个没有ID的根视图。 And the tools show that the activity B is on the top. 工具显示活动B在顶部。 I know the view with id R.id.content is the root view of an Activity .But I don't know why it is still there after finish() is called. 我知道id为R.id.content的视图是Activity的根视图,但是我不知道为什么在调用finish()之后它仍然存在。 You know, there is no other logic after finish() and no other receiver there, or any other can block to finish. 您知道, finish()之后没有其他逻辑,那里没有其他接收者,或者任何其他接收者都可以阻塞完成。

Maybe it is an issue about my wrong use of ActivityGroup . 也许是因为我对ActivityGroup使用不正确。 Can anyone help? 有人可以帮忙吗?

Thanks for your answers for my first question on stackoverflow. 感谢您对我关于stackoverflow的第一个问题的回答。

我知道根本原因,这是因为我使用了B的singleTask活动,但其他一些活动却作为新任务启动,但仍未完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM