0

嗨,我需要将我的应用程序中的文本分享到 Facebook 我试过这段代码

Intent sharingIntent = new Intent(Intent.ACTION_SEND);
        sharingIntent.setType("text/plain");
        sharingIntent.putExtra(Intent.EXTRA_SUBJECT, DESCRIPTION);
        sharingIntent.putExtra(Intent.EXTRA_TEXT, DESCRIPTION);
        PackageManager packManager = getPackageManager();
        List<ResolveInfo> resolvedInfoList = packManager.queryIntentActivities(sharingIntent,        PackageManager.MATCH_DEFAULT_ONLY);

        boolean resolved = false;
        for(ResolveInfo resolveInfo: resolvedInfoList){
            if(resolveInfo.activityInfo.packageName.startsWith("com.facebook.katana")){
                sharingIntent.setClassName(
                    resolveInfo.activityInfo.packageName, 
                    resolveInfo.activityInfo.name );
                resolved = true;
                break;
            }
        }
        if(resolved){
            startActivity(sharingIntent);
        }else{

             android.app.AlertDialog.Builder alert  = new   AlertDialog.Builder(SingleItemView.this);
                alert.setTitle("Warning");
                alert.setMessage("Facebook App not found");
                alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog,int which) 
                    {
                        dialog.dismiss();

                    }
                });
                alert.show();
        } 

它通过安装的 Facebook 打开 Facebook 帖子,但使用空白帖子我如何将我的文本传递给 Facebook 应用程序?

4

2 回答 2

3

试试这个方法,希望这能帮助你解决你的问题。

现在 Facebook API 不支持为用户预填充消息,如本政策所示:https ://developers.facebook.com/policy/

或者

检查此讨论:https ://developers.facebook.com/bugs/332619626816423

于 2014-11-06T04:18:56.017 回答
0

据我所知,Facebook 只允许共享链接。因此,您所做的意图很好,但请尝试共享 http:// 链接。它共享站点并允许用户对他们共享的链接发表评论。

于 2014-11-05T06:59:24.627 回答