-2

In my application I want to be able to share some content which are images from my app to Facebook, Instagram and Twitter. I know i can send a broadcast to do that using the below code:

Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("plain/text");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is the text that will be shared.");
startActivity(Intent.createChooser(sharingIntent,"Share using"));

but my problem is that I wanna get a callback that tells me if the user has shared the content(image) or not. Is there any kind of way to do this? What about the Facebook sdk? Does it provide such a functionality? I've searched about Instagram and it seems that they don't provide such a funcionality. What about Twitter?

arash moeen
  • 4,533
  • 9
  • 40
  • 85
  • without facebook sdk, i dont think so you can share things from android to facebook. – Jamil May 09 '15 at 09:55
  • @Softcoder you can easily share anything on facebook without its sdk. it's a simple broadcast and facebook app itself handles it with its own dialog and stuff. but there will be no callback for that. I assume facebook sdk will give you some callback to handle whether the content is shared or not . but thanks anyway – arash moeen May 09 '15 at 10:02
  • plz see this http://stackoverflow.com/questions/25402706/android-share-text-not-showing-up-in-facebook/25402734#25402734 – Jamil May 09 '15 at 10:07

1 Answers1

0

You can do it very easily to get call back.

Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("plain/text");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is the text that will be shared.");
startActivityForResult(Intent.createChooser(sharingIntent,"Share using"));

Use startActivityForResult instead of startActivity and override OnActivityResult in which check your result code is RESULT_OK or not.If it is that you have successfully posted your content other wise your post was not successful.

Jay Shah
  • 732
  • 4
  • 16
  • But I think if the application doesn't send any result, the default result will be **RESULT_OK**... isn't that true? I'm just asking – arash moeen May 09 '15 at 09:47
  • Give it a try working or not I think this should work. – Jay Shah May 09 '15 at 09:52
  • it doesn't work. It always returns 0 because the activity should handle the resultcode which in my case facebook doesn't. I should go and check sdk – arash moeen May 09 '15 at 11:26