[英]Android: Activity is not destroyed using the command 'finishActivity(999)'
My currently running activity B should be destroyed using 'finishActivity(999)'. 我当前正在运行的活动B应该使用“ finishActivity(999)”销毁。 Doing so, I want to get back to the method 'onActivityResult' in activity A which called activity B. This somehow doesn't work.
这样做之后,我想回到活动A中称为活动B的方法“ onActivityResult”。这在某种程度上是行不通的。 Below some code snippets:
下面是一些代码片段:
public class ActivityB extends Activity {
...
// Method listening OnClick event
public void verifyPassword(View view) {
...
// call http server in order to verify password
if (httpResponse != 200) {
finishActivity(999);
}
command Z;
}
I can see that in the debugger that the finishActivity(999) statement is performed, but after that, simply the next instruction 'command Z' in the same activiy is executed. 我可以看到在调试器中执行了finishActivity(999)语句,但是此后,仅执行同一活动中的下一条指令“命令Z”。
Why does the finishActivity(999) statement has no effect? 为什么finishActivity(999)语句无效?
finishActivity()
doesn't finish the current activity: finishActivity()
不能完成当前活动:
Force finish another activity that you had previously started with startActivityForResult(Intent, int).
强制完成您之前使用startActivityForResult(Intent,int)开始的另一个活动。
Note another activity , not this activity (eg you could call it from activity a). 注意另一个活动 ,而不是这个活动 (例如,您可以从活动a调用它)。
You want just finish()
instead, most likely in combination with setResult()
. 您只需要
finish()
,最有可能与setResult()
结合使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.