Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
意向共享facebook-Android_Android_Facebook - Fatal编程技术网

意向共享facebook-Android

意向共享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

我想在facebook messenger应用程序上分享一张安卓活动的图片,该应用程序已经在我的设备上打开,并驻留在安卓设备的最近任务中

我正在使用以下代码共享图像,但它正在messenger“单独共享”中打开一个新活动,但我想将其共享到已打开的聊天室

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