2015-05-09 138 views
-2

在我的应用程序中,我希望能够分享一些来自我的应用程序的图像内容到Facebook,Instagram和Twitter。我知道我可以发送一个广播,使用下面的代码来完成:在Facebook,Instagram和Twitter上分享Android应用程序

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,似乎他们不提供这样的funcionality。那么Twitter呢?

+0

没有Facebook的SDK,我不这么认为,你可以分享从Android到Facebook的东西。 – Jamil

+0

@Softcoder你可以轻松地在facebook上分享任何东西,而无需其sdk。这是一个简单的广播和Facebook应用程序本身处理它与自己的对话和东西。但不会有任何回调。我认为facebook sdk会给你一些回调来处理内容是否被共享。但是,无论如何谢谢 –

+0

PLZ看到这个http://stackoverflow.com/questions/25402706/android-share-text-not-showing-up-in-facebook/25402734#25402734 – Jamil

回答

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或not.If它是您已成功发布您的内容等你的英明后未成功的。

+0

但我认为,如果应用程序不发送任何结果,默认结果将是** RESULT_OK ** ...是不是真的?我只是问 –

+0

试试看还是不行我认为这应该有效。 –

+0

它不起作用。它总是返回0,因为该活动应该处理结果代码,在我的情况下,Facebook没有。我应该去检查sdk –

相关问题