Facebook,Instagram和Twitter上的Android应用分享

时间:2015-05-09 09:18:33

标签: android facebook android-intent twitter

在我的应用程序中,我希望能够将我的应用程序中的图像内容分享到Facebook,Instagram和Twitter。我知道我可以使用以下代码发送广播:

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"));

但我的问题是我想得到一个回调,告诉我用户是否共享了内容(图片)。有没有办法做到这一点? Facebook sdk怎么样?它提供这样的功能吗?我搜索过Instagram,似乎他们没有提供这样的功能。 Twitter怎么样?

1 个答案:

答案 0 :(得分:0)

您可以非常轻松地接听电话。

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"));

使用 startActivityForResult 代替 startActivity 并覆盖 OnActivityResult ,其中检查结果代码是否为 RESULT_OK 。如果您已经成功发布了其他内容,那么您的帖子就不会成功。