Onactivityresult Being Called Instantly
Solution 1:
You cannot use startActivityForResult()
if the activity being started is not running in the same task as the activity that starts it. This means that neither of the activities can have launchMode="singleInstance"
. If you require that these 2 activities run in different tasks, then you need to use a different mechanism. The documentation for startActivityForResult()
sorta-kinda hints at this:
"For example, if the activity you are launching uses the singleTask launch mode, it will not run in your task and thus you will immediately receive a cancel result."
What you can do is to simply start the activity using startActivity()
and have the called activity call startActivity()
to return to your activity, sending back data as necessary as extras in the Intent
it uses.
However, you might consider whether you really need these special launchModes. In general they are only necessary for HOME-screen replacements and other very special applications. Most developers who use singleInstance
or singleTask
launch modes are using them incorrectly.
Post a Comment for "Onactivityresult Being Called Instantly"