我需要在Facebook上分享文字。我通过意图以编程方式发送文本。代码正常工作,对话框已打开但文本未显示在共享帖子上。
代码:
PackageManager pm=getPackageManager();
try {
Intent waIntent = new Intent(Intent.ACTION_SEND);
waIntent.setType("text/plain");
PackageInfo info=pm.getPackageInfo("com.facebook.katana", PackageManager.GET_META_DATA);
waIntent.setPackage("com.facebook.katana");
String msg = "Corporate1 Facebook Post";
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setPackage("com.facebook.katana");
intent.setAction(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, msg);
startActivity(intent);
}catch (PackageManager.NameNotFoundException e) {
Toast.makeText(getBaseContext(), "Facebook not Installed", Toast.LENGTH_SHORT)
.show();
}
}