Android - startActivityForResult immediately triggering onActivityResult
Additionally make sure the intent does not have the Intent.FLAG_ACTIVITY_NEW_TASK
set.
From the docs:
This flag can not be used when the caller is requesting a result from the activity being launched.
You can't use startActivityForResult()
if your activity is being launched as a singleInstance
or singleTask
. standard
or singleTop
launch mode will fix the problem.
I have seen this behavior before, please make sure your destnation activity (that special activity) is not singleInstance
in AndroidManifest file. If the Activity is singleInstance
, then it will return RESULT_CANCELED
before launched!