Difference Between Pendingintent.send(...) And Activity.startintentsenderforresult(...)
There seem to be (at least) two ways to send Intents in Android: PendingIntent.send(...) Activity.startIntentSenderForResult(PendingIntent.getIntentSender(), ...) Other than the
Solution 1:
Seems like these two approaches are very different:
- The
start...forResult(...)
methods start an intent or sub-activity in a way that allows for a result to be returned to the activity that executed thestart...forResult(...)
. The result will be passed back to the activity'sonActivityResult(...)
method. - All other ways of launching intents or sub-activities (including
PendingIntent.send(...)
) act in a fire-and-forget-manner and don't allow for any results to be returned. TheOnFinished
handler is called as soon as the launch is sent, whether or not it takes a while to complete. The data passed into this handler, therefore, does not necessarily have anything to do with what you would otherwise receive viaonActivityResult(...)
. In fact, in my case, theOnFinished
handler is always called right away, before the dialog of the sub-activity even shows up, with aresultCode
ofActivity.RESULT_CANCELED
.
What a mess...
Post a Comment for "Difference Between Pendingintent.send(...) And Activity.startintentsenderforresult(...)"