Successful share intent for android

2019-01-08 16:49发布

问题:

How can i tell if a user successfully completed a share intent? For instance if a user wanted to share an app via Facebook or Twitter.

Edit:

I am not looking at how to create an Intent for sharing. I want to know if the user actually shared anything. Or did the user hit the cancel button.

回答1:

I don't think there is an assured way to do it.

You could initiate the send using startActivityForResult() and hope that the activity which handles the Intent replies with a RESULT_OK. But you can't rely on it to work always.



回答2:

For twitter - the "data" object in OnActivityResult is null when the user cancels the share.



回答3:

You have use the Intent.ACTION_SEND, and the system will display a list of applications (on the device) where you can share. This website explains how:

http://sudarmuthu.com/blog/sharing-content-in-android-using-action_send-intent