调用 finish() 后 ActivityGroup 的子 Activity 尚未完成
我有一个使用 ActivityGroup 的程序。 类结构如下:
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 是整个程序的入口。 在 B 的 onCreate()
中,我使用 startActivityResult()
启动 C;在C中,它将向用户显示一个按钮;用户点击按钮后,C 将调用 finish()
和 setResult();
,然后在 B 的 onActivityResult()
中, 我尝试使用方法 finish()
退出所有应用程序。
问题是按下按钮后屏幕变黑。然后我也使用 hierarchyviewer.bat
查看视图;令我惊讶的是,有一个带有 id R.id.content
的视图和另一个没有 id 的根视图。工具显示活动 B 位于顶部。 我知道 id 为 R.id.content
的视图是 Activity
的根视图。但我不知道为什么在 finish( )
被调用。您知道,finish()
之后没有其他逻辑,并且那里没有其他接收器,或者任何其他可以阻止完成。
也许这是我错误使用 ActivityGroup
的问题。有人可以帮忙吗?
感谢您对我在 stackoverflow 上的第一个问题的回答。
I have a program using 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.
In B's onCreate()
, I use startActivityResult()
to launch C; in C, it will show user a button; after user clicks the button, C will call finish()
and setResult();
then in B's onActivityResult()
,
I try use the method finish()
to exit all of the application.
The problem is that the screen turns into black after press the button. Then I use hierarchyviewer.bat
too see the views; to my suprise, there are a view with id R.id.content
and another root view without id. And the tools show that the activity B is on the top.
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. You know, there is no other logic after finish()
and no other receiver there, or any other can block to finish.
Maybe it is an issue about my wrong use of ActivityGroup
. Can anyone help?
Thanks for your answers for my first question on stackoverflow.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道根本原因,那是因为我使用了 B 的 singleTask 活动,但其他一些活动作为新任务启动但仍未完成。
I know the root cause, that's because I used a singleTask activity of B but some other activities are started as new task and still not finished.