调用完成()在Android的活动实际上并没有完成 [英] Calling finish() on an Android activity doesn't actually finish
问题描述
我打电话完成()
,但我的活动不断前进。
I'm calling finish()
but my activity keeps on going.
我是从主要活动画面的菜单调用的活动。在我的活动的的onCreate()
方法,我有以下的code片段:
I have an activity which is invoked by a menu from the main activity screen. In my activity's onCreate()
method I have the following code fragment:
// Make sure there are some events in the list.
if (theEventArrayList.isEmpty()){
Toast.makeText(this, "Event List is empty", Toast.LENGTH_LONG).show();
finish();
}
SummarizeCurrentEvent();
graphEvents();
如果该列表是空的搭设的面包,我可以在调用完成设置断点()
。如果我从在调试步骤它去直接 SummarizeCurrentEvent()
。我以为完成()
将退出该活动。这是不是这样的?我在哪里可以找到有关该方法的详细信息?
If the list is empty it puts up the Toast, and I can set breakpoint on the call to finish()
. If I step from that in the debugger it goes to straight to SummarizeCurrentEvent()
. I thought finish()
would exit the activity. Is this not the case? Where can I find out more information about this method?
推荐答案
您应该把返回
的完成后声明
,因为那个叫完成
将被完全执行,否则
You should put a return
statement after that finish
, because the method that called finish
will be executed completely otherwise.
也看到了这个问题:关于Android的完成()
also, see this question: about finish() in android
这篇关于调用完成()在Android的活动实际上并没有完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!