Sop*_*hie 5 android facebook android-intent android-facebook
如何在Facebook上分享文本和图像,我正在写一个教会应用程序,我想让用户与URL共享文本和图像.
我可以分享在线应用程序链接但无法共享文本和图像,我在哪里缺少?
我的代码看起来像这样:
Button btnFbSharing = (Button) findViewById(R.id.fbSharing);
btnFbSharing.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(android.content.Intent.EXTRA_TITLE, "Church Application");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "https://play.google.com/store/apps/details?id=com.facebook.katana");
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "A new world begin");
shareIntent.putExtra(android.content.Intent.EXTRA_STREAM, R.drawable.ic_launcher);
PackageManager pm = getApplicationContext().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);
}
}
}
});
Run Code Online (Sandbox Code Playgroud)
嘿,当我问同样的问题时,我对此做了很多研究
基本上,在 Facebook 应用程序中使用包名称“com.facebook.katana”是不可能的,因为当图像存在时它会忽略额外的文本,请参阅此内容以了解实际错误,但当图像不存在时可以有链接。我知道很烦人。
经过大量研究后,我使用 facebook sdk 3.14.1 创建了自己的活动,它允许图像和文本,这里是演示项目的github 链接,尝试一下,让知道它是否对您有帮助。
| 归档时间: |
|
| 查看次数: |
17892 次 |
| 最近记录: |