意向共享facebook-Android
我想在facebook messenger应用程序上分享一张安卓活动的图片,该应用程序已经在我的设备上打开,并驻留在安卓设备的最近任务中 我正在使用以下代码共享图像,但它正在messenger“单独共享”中打开一个新活动,但我想将其共享到已打开的聊天室意向共享facebook-Android,android,facebook,Android,Facebook,我想在facebook messenger应用程序上分享一张安卓活动的图片,该应用程序已经在我的设备上打开,并驻留在安卓设备的最近任务中 我正在使用以下代码共享图像,但它正在messenger“单独共享”中打开一个新活动,但我想将其共享到已打开的聊天室 String mimeType = "image/*"; Intent intent = new Intent(Intent.ACTION_SEND); intent.setPackage("com.facebook.orca"); inten
String mimeType = "image/*";
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setPackage("com.facebook.orca");
intent.setType(mimeType);
intent.putExtra(Intent.EXTRA_STREAM, contentUri);
intent.putExtra(EXTRA_PROTOCOL_VERSION, PROTOCOL_VERSION);
intent.putExtra(EXTRA_APP_ID, YOUR_APP_ID);
activity.startActivityForResult(shareIntent, SHARE_TO_MESSENGER_REQUEST_CODE);
Facebook已经限制了帖子上的文本共享。它将支持有效的URL链接共享或图像共享。所以我发布了引用自的代码
Facebook已经限制了帖子上的文本共享。它将支持有效的URL链接共享或图像共享。所以我发布了引用自的代码
private void shareAppLinkViaFacebook(String urlToShare) {
try {
Intent intent1 = new Intent();
intent1.setClassName("com.facebook.katana", "com.facebook.katana.activity.composer.ImplicitShareIntentHandler");
intent1.setAction("android.intent.action.SEND");
intent1.setType("text/plain");
intent1.putExtra("android.intent.extra.TEXT", urlToShare);
startActivity(intent1);
} catch (Exception e) {
// If we failed (not native FB app installed), try share through SEND
String sharerUrl = "https://www.facebook.com/sharer/sharer.php?u=" + urlToShare;
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(sharerUrl));
startActivity(intent);
}
}