1
我正在嘗試設置社交分享。當我選擇共享時,它顯示所有可用選項時工作正常。但是,無論如何,我可以檢查用戶是否選擇「Facebook」作爲他們的共享方法。我想在發生這種情況時觸發相關facebok sdk相關代碼。如果我不採用他們的SDK路由不同於其他共享選項,Facebook似乎限制了可以發佈的內容。識別用戶是否選擇Facebook作爲社交分享選項
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if(id == R.id.social_share){
//working - this opens up available sharing options on device.
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(android.content.Intent.EXTRA_SUBJECT, "A Title");
i.putExtra(Intent.EXTRA_TEXT, "This is content... ");
startActivity(i.createChooser(i, "Share"));
//I want to use this code if facebook is selected.
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("Hello Facebook")
.setContentDescription(
"The 'Hello Facebook' sample showcases simple Facebook integration")
.setContentUrl(Uri.parse("http://developers.facebook.com/android"))
.build();
.setImageUrl(Uri.parse("http://....."))
shareDialog.show(linkContent);
}
}
return true;
}