分享到Facebook故事 [英] Sharing to Facebook Stories

查看:127
本文介绍了分享到Facebook故事的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

遵循

We were able to implement sharing to Instagram Stories, but not to Facebook Stories, following these instructions . Android is not able to find an app for the intent com.facebook.stories.ADD_TO_STORY, despite Facebook app being installed and updated. Has anybody been able to accomplish that?

推荐答案

这可能为时已晚,但我想回答一下,如果它可以帮助那些在没有Intent Chooser对话框的情况下分享到instagram可能会遇到问题的人.

It might be too late but i thought to answer it if it can help people who might be facing issues in sharing to instagram without Intent Chooser dialog.

Facebook希望我们启动一个意图选择器对话框,以便从Facebook应用程序本身中的4个-5个活动中进行选择,这些活动可以将com.facebook.stories.ADD_TO_STORY作为动作进行处理.

Facebook expects us to launch an intent chooser dialog to select from 4 -5 activities within facebook app itself that can handle com.facebook.stories.ADD_TO_STORY as action.

尽管如此,这是我用来从facebook应用程序启动确切的故事编辑器屏幕的代码.它使用ACTION_SEND而不是com.facebook.stories.ADD_TO_STORY. 因此,首先在清单的application标签内定义一个文件提供程序

Nevertheless here is the code i used to launch the exact story editor screen from facebook app. It uses ACTION_SEND instead of com.facebook.stories.ADD_TO_STORY. So First define a fileprovider inside application tag in manifest

<provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="${applicationId}.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_provider_paths" />
        </provider>

然后将file_provider_paths.xml保留在res目录的xml文件夹中. file_provider_paths.xml

Then keep file_provider_paths.xml inside xml folder in res directory. file_provider_paths.xml

<paths>
    <external-path
        name="share"
        path="/" />
</paths>

然后准备一个您要共享的文件

Then perpare a uri of file you want to share

File file = new File(imagePath);
Uri fileUri = FileProvider.getUriForFile(getApplicationContext(),getPackageName()+".fileprovider",file);

然后将意图发送给Facebook,如下所示

Then send intent to facebook as below

Intent storiesIntent = new Intent(Intent.ACTION_SEND);
storiesIntent.setComponent(new ComponentName("com.facebook.katana", "com.facebook.composer.shareintent.AddToStoryAlias"));
storiesIntent.setDataAndType(uri, "image/*");//for background image
storiesIntent.putExtra("interactive_asset_uri", uri);//for sticker assets
storiesIntent.putExtra("content_url", "https://dexati.com/");
grantUriPermission("com.facebook.katana", uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivityForResult(storiesIntent, 0);

在这里,我们明确调用了Facebook应用的故事编辑器活动.

Here we are making explicit call to the story editor activity of facebook app.

这篇关于分享到Facebook故事的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆