android中的照片共享意图

android中的照片共享意图,android,android-intent,android-photos,android-sharing,Android,Android Intent,Android Photos,Android Sharing,我使用上述代码在社交网站上共享图像。当我在facebook上发布图像时,只会发布文本,而图像不会出现。如何获取图像和路径图像是字符串变量我正在获取服务器图像路径并存储在字符串变量中。但它不起作用。请为我的上述问题提供任何解决方案。?试试这个 Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); shareInten

我使用上述代码在社交网站上共享图像。当我在facebook上发布图像时,只会发布文本,而图像不会出现。如何获取图像和路径图像是字符串变量我正在获取服务器图像路径并存储在字符串变量中。但它不起作用。请为我的上述问题提供任何解决方案。?

试试这个

Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
shareIntent.setType("image/*");

Uri uri = Uri.parse(pathToImage);
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
return shareIntent;
参考更多链接

试试这个

Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
shareIntent.setType("image/*");

Uri uri = Uri.parse(pathToImage);
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
return shareIntent;
参考更多链接


您不能使用Intent发布到Facebook。他们专门阻止了这一点。你要么使用他们的SDK,要么将其复制到剪贴板,让用户在facebook界面打开后粘贴它。我也有同样的问题。

您不能使用Intent向Facebook发帖。他们专门阻止了这一点。你要么使用他们的SDK,要么将其复制到剪贴板,让用户在facebook界面打开后粘贴它。我也遇到了同样的问题。

这是我提出的解决方案: 如果您知道软件包名称,此功能允许您共享到instagram、facebook或任何其他应用程序。如果未安装应用程序,它将重定向到Play Store。如果您将“其他”作为参数发送,您将显示也支持图像共享的应用程序列表

Bitmap icon = mBitmap;
    Intent share = new Intent(Intent.ACTION_SEND);
    share.setType("image/jpeg");
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    icon.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
    File f = new File(Environment.getExternalStorageDirectory() + File.separator + "temporary_file.jpg");
    try {
        f.createNewFile();
        FileOutputStream fo = new FileOutputStream(f);
        fo.write(bytes.toByteArray());
    } catch (IOException e) {                       
            e.printStackTrace();
    }
    share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/temporary_file.jpg"));
    startActivity(Intent.createChooser(share, "Share Image"));

这就是我提出的解决方案: 如果您知道软件包名称,此功能允许您共享到instagram、facebook或任何其他应用程序。如果未安装应用程序,它将重定向到Play Store。如果您将“其他”作为参数发送,您将显示也支持图像共享的应用程序列表

Bitmap icon = mBitmap;
    Intent share = new Intent(Intent.ACTION_SEND);
    share.setType("image/jpeg");
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    icon.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
    File f = new File(Environment.getExternalStorageDirectory() + File.separator + "temporary_file.jpg");
    try {
        f.createNewFile();
        FileOutputStream fo = new FileOutputStream(f);
        fo.write(bytes.toByteArray());
    } catch (IOException e) {                       
            e.printStackTrace();
    }
    share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/temporary_file.jpg"));
    startActivity(Intent.createChooser(share, "Share Image"));

Environment.getExternalStorageDirectory()+File.separator+“temporary_File.jpg”这一行表示在本地和u r上存储图像,并在uri.parse方法中提供临时_file.jpg名称和ur解析图像。但我希望直接获取图像路径,并希望直接在社交网站上发布图像。我直接从服务器获取图像路径,我将dat路径提供给uri.parse()method.dats不起作用。最后,我的问题是,我正在获取图像路径,但dat没有张贴在墙上?请检查图像路径,并尝试将其保存在临时文件夹中,然后替换它们,以便文件夹的路径保持不变。您说,首先我们必须将服务器图像也保存在本地,获取图像的路径并在墙上显示是否正确。这是什么mBitmap.Environment.getExternalStorageDirectory()+File.separator+“temporary\u File.jpg”的数据类型这一行表示在本地和u r上存储图像,并在uri.parse方法中提供临时_file.jpg名称和ur解析图像。但我希望直接获取图像路径,并希望直接在社交网站上发布图像。我直接从服务器获取图像路径,我将dat路径提供给uri.parse()method.dats不起作用。最后,我的问题是,我正在获取图像路径,但dat没有张贴在墙上?请检查图像路径,并尝试将其保存在临时文件夹中,然后替换它们,以便文件夹的路径保持不变。您说,首先我们必须将服务器图像也保存在本地,获取图像的路径并在墙上显示是否正确。这是什么mBitmap的数据类型。的可能副本的可能副本