如何在Facebook上分享使用意向文本和图像 [英] How to share Text and Image on Facebook using Intent

查看:440
本文介绍了如何在Facebook上分享使用意向文本和图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Facebook上分享文本和图像,我写在这我想允许用户使用URL一起分享文字和图片教会的应用。

我能够分享在线应用程序链接,但无法分享文字和放大器;形象,我丢失在哪里?

我的code是这样的:

 按钮btnFbSharing =(按钮)findViewById(R.id.fbSharing);
        btnFbSharing.setOnClickListener(新OnClickListener(){            @覆盖
            公共无效的onClick(查看为arg0){
                // TODO自动生成方法存根                 意图shareIntent =新意图(android.content.Intent.ACTION_SEND);
                 shareIntent.setType(text / plain的);
                 shareIntent.putExtra(android.content.Intent.EXTRA_TITLE,教会应用程序);
                 shareIntent.putExtra(android.content.Intent.EXTRA_TEXThttps://play.google.com/store/apps/details?id=com.facebook.katana);
                 shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,一个新的世界开始);                 shareIntent.putExtra(android.content.Intent.EXTRA_STREAM,R.drawable.ic_launcher);
                 软件包管理系统PM = getApplicationContext()getPackageManager()。
                 清单< ResolveInfo> activityList = pm.queryIntentActivities(shareIntent,0);
                 对于(最终ResolveInfo应用:activityList){
                    如果((app.activityInfo.name)。载有(脸谱)){
                        最后ActivityInfo活性= app.activityInfo;
                        最终的组件名NAME =新的组件名(
                                    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(名);
                        startActivity(shareIntent);
                       }
                 }
            }
        });


解决方案

嘿,我做了很多的研究,这是我问了同样的<一个href=\"http://stackoverflow.com/questions/23787429/share-image-and-text-to-facebook-on-android\">question

基本上它是不是从使用的包名com.facebook.katanaFacebook应用程序可能因为它忽略多余的文字时,图像有看到这个实际的错误但可以有链接时的形象是不存在。很讨厌我知道了。

在很多找我关于使用Facebook SDK 3.14.1,让图像和文字在这里是的 GitHub的链接的示范项目给它一个去,让知道,如果它可以帮助你。

How to share Text and Image on Facebook, I am writing a Church Application in which i want to allow user to share text and image along with URL.

I am able to share online app link but not able to share text & image, where i am missing ?

my code looks like this:

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);
                       }
                 }                  
            }
        });

解决方案

Hey I did a lot of research into this as I asked the same question

Basically it is not possible from the facebook app using the package name "com.facebook.katana" as it ignores the extra text when the image is there see this for actual bug but can have links when the image is not there. Very annoying I know.

After a lot of looking about I created my own activity using the facebook sdk 3.14.1 which allows images and text here is the github link to the demo project give it a go and let know if it helps you out.

这篇关于如何在Facebook上分享使用意向文本和图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆