我无法使用共享意图代码在Facebook上发布数据

时间:2016-03-26 10:51:49

标签: android facebook android-intent

 private void shareonfb(){
        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        shareIntent.setType("text/plain");
        shareIntent.putExtra(Intent.EXTRA_TEXT, "Content to share");
        PackageManager pm = getPackageManager();
        List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0);
        for (final ResolveInfo app : activityList) {
            if ((app.activityInfo.name).contains("facebook")) {
                final ActivityInfo activity = app.activityInfo;
                final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name);
                shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
                shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |             Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
                shareIntent.setComponent(name);
                startActivity(shareIntent);
                break;
            }
        }
    }

当我尝试使用Extra文本在fb上发布时,数据无法发布它是空的

1 个答案:

答案 0 :(得分:1)

您无法预先填写用户消息,因为这违反了Facebook的平台政策。您尝试添加的任何消息都将被应用删除。

https://developers.facebook.com/policy#control