您好我需要将我的应用程序中的文字分享给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应用程序?
答案 0 :(得分:3)
答案 1 :(得分:0)
据我所知,Facebook只允许共享链接。所以你的意图很好,但尝试共享一个http://链接。它共享该站点并允许用户对他们共享的链接发表评论。