【问题标题】:Android - ACTION_SEND image from bitmapAndroid - 位图中的 ACTION_SEND 图像
【发布时间】:2014-05-22 18:02:52
【问题描述】:

我正在尝试将图像发送到其他应用程序,但使用此代码不起作用。 (删除文件或显示文件的其他操作,有效)

ByteArrayOutputStream bos = new ByteArrayOutputStream();  
myBitmap.compress(CompressFormat.JPEG, 100, bos);  
Intent intent = new Intent(); 
intent.setAction(Intent.ACTION_SEND); 
intent.setType("image/jpeg"); 
intent.putExtra(Intent.EXTRA_STREAM, bos.toByteArray());
startActivity(Intent.createChooser(intent, getString(R.string.app_name)));

当我从其他应用程序发送“图像”时,这些崩溃

【问题讨论】:

    标签: android android-intent bitmap bytearray bytearrayoutputstream


    【解决方案1】:

    试试这个代码

    Intent i = new Intent(Intent.ACTION_SEND);
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    i.setType("image/jpg");
    i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/Pictures/
     image.jpg"));  // choose your path of the image
    startActivity(i);
    

    希望对你有帮助

    【讨论】:

    • 它会工作,但我不想发送电子邮件..只是从非静态字符串发送图像
    • @user3657513 试试这个对我有用的新代码,谢谢
    猜你喜欢
    • 2013-05-29
    • 1970-01-01
    • 2013-12-18
    • 2013-06-14
    • 2022-07-21
    • 2011-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多