Android的 - startActivityForResult立即触发onActivityResult [英] Android - startActivityForResult immediately triggering onActivityResult
问题描述
我现在用的是调用启动我的应用程序的主要活动活动 startActivityForResult(意向,ACTIVITY_TYPE)
,和他们都工作,但之一。
I am launching activities from the main activity in my app using the call startActivityForResult(intent, ACTIVITY_TYPE)
, and they are all working but one.
这一次,调用时,启动该活动根据需要,但在日志中我可以看到 onActivityResult()
立即被触发。活动显示了,但 RESULT_CANCELLED
立即返回 onActivityResult()
。
This one, when called, launches the activity as desired, but in the log I can see that onActivityResult()
is immediately being triggered. The activity shows up but RESULT_CANCELLED
is immediately returned to onActivityResult()
.
我再与活动,preSS一个按钮,它调用交互完成()
和 onActivityResult()
不叫的时候(因为很明显的结果已经返回)。
I then interact with the activity, press a button which calls finish()
, and onActivityResult()
is not called the time (because apparently a result has already been returned).
这是否有意义人吗?有没有人见过这种行为之前?
Does this make sense to anyone? Has anyone seen this behavior before?
推荐答案
您无法使用 startActivityForResult()
如果你的活动正在启动一个 singleInstance
或 singleTop
。
You can't use startActivityForResult()
if your activity is being launched as a singleInstance
or singleTop
.
这篇关于Android的 - startActivityForResult立即触发onActivityResult的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!