Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用intent共享图像和文本在android中不起作用?_Android_Facebook_Android Intent - Fatal编程技术网

使用intent共享图像和文本在android中不起作用?

使用intent共享图像和文本在android中不起作用?,android,facebook,android-intent,Android,Facebook,Android Intent,我想使用intent共享图像和文本,但它不起作用 当FacebookIntent启动时,它只显示我想要共享的文本和图像 你可以在这里查看图片 List<Intent> targetShareIntents=new ArrayList<Intent>(); Intent shareIntent=new Intent();

我想使用intent共享图像和文本,但它不起作用 当FacebookIntent启动时,它只显示我想要共享的文本和图像

你可以在这里查看图片

 List<Intent> targetShareIntents=new ArrayList<Intent>();
                                            Intent shareIntent=new Intent();
                                            shareIntent.setAction(Intent.ACTION_SEND);
                                            shareIntent.setType("text/plain");
                                            List<ResolveInfo> resInfos=getPackageManager().queryIntentActivities(shareIntent, 0);
                                            if(!resInfos.isEmpty())
                                            {

                                                for(ResolveInfo resInfo : resInfos)
                                                {
                                                    String packageName=resInfo.activityInfo.packageName;
                                                    Log.i("Package Name", packageName);
                                                    if(packageName.contains("com.facebook.katana"))
                                                    {
                                                        String imageurl="/storage/emulated/0/iWally/explosion_3-wallpaper-1024x768.jpg";
                                                        String text="hello how are you";
                                                        Intent intent=new Intent();
                                                        intent.setType("image/*");
                                                        intent.setComponent(new ComponentName(packageName, resInfo.activityInfo.name));
                                                        intent.setAction(Intent.ACTION_SEND);
                                                        intent.putExtra(Intent.EXTRA_TEXT,text);
                                                        intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+imageurl.toString()));
                                                        intent.setPackage(packageName);
                                                        targetShareIntents.add(intent);
                                                    }
                                                }

                                                if(!targetShareIntents.isEmpty())
                                                {
                                                    System.out.println("Have Intent");
                                                    Intent chooserIntent=Intent.createChooser(targetShareIntents.remove(0), "Choose app to share");
                                                    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetShareIntents.toArray(new Parcelable[]{}));
                                                    startActivity(chooserIntent);
                                                }
                                                else
                                                {
                                                     Uri uri = Uri.parse("market://details?id=com.facebook.katana"); 
                                                     Intent intent = new Intent(Intent.ACTION_VIEW, uri); 
                                                     startActivity(intent);
                                                    System.out.println("Do not Have facebook");

                                                }
                                            }

List targetShareIntents=new ArrayList();
意向共享意向=新意向();
shareIntent.setAction(Intent.ACTION\u SEND);
shareIntent.setType(“文本/普通”);
List ResInfo=getPackageManager().QueryInputActivities(shareIntent,0);
如果(!resinfo.isEmpty())
{
对于(ResolveInfo resInfo:resInfo)
{
字符串packageName=resInfo.activityInfo.packageName;
Log.i(“包名”,packageName);
如果(packageName.contains(“com.facebook.katana”))
{
字符串imageurl=“/storage/emulated/0/iWally/explosion_3-wallper-1024x768.jpg”;
String text=“你好”;
意图=新意图();
intent.setType(“image/*”);
setComponent(新组件名(packageName、resInfo.activityInfo.name));
intent.setAction(intent.ACTION\u SEND);
intent.putExtra(intent.EXTRA_TEXT,TEXT);
intent.putExtra(intent.EXTRA_流,Uri.parse(“文件:/”+imageurl.toString());
intent.setPackage(packageName);
targetShareIntents.add(意图);
}
}
如果(!targetShareIntents.isEmpty())
{
System.out.println(“有意向”);
Intent-chooserint=Intent.createChooser(targetShareIntents.remove(0),“选择要共享的应用程序”);
选择content.putExtra(Intent.EXTRA_INITIAL_INTENTS,targetShareIntents.toArray(新地块[]{}));
开始触觉(选择内容);
}
其他的
{
Uri=Uri.parse(“market://details?id=com.facebook.katana"); 
意图=新意图(Intent.ACTION\u视图,uri);
星触觉(意向);
System.out.println(“没有facebook”);
}
}

嘿,当我提出同样的问题时,我做了很多研究

从facebook应用程序使用“com.facebook.katana”基本上是不可能的,因为它会在有图像时忽略额外的文本,但在图像不存在时可以有链接。我知道这很烦人


在查看了很多之后,我使用facebook sdk 3.14.1创建了自己的活动,它允许图像和文本,请尝试一下,并告知它是否对您有帮助。

我想共享文本和图像,但目前使用此代码,仅共享图像,不共享文本