本文介绍了如何安装位图到电子邮件的android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我已经保存在外部存储的位图。我已经有负载和返回位图的方法。我的问题是,我怎么这个图像附加到电子邮件的意图。

注:我知道如何启动电子邮件的意图,我只需要知道如何安装位图。谢谢你。

这是怎么了保存图:

 私人无效savePicture(字符串文件名,位图B,上下文CTX){
    尝试{
        FileOutputStream中出;
        OUT = ctx.openFileOutput(文件名,Context.MODE_WORLD_READABLE);        b.com preSS(Bitmap.Com pressFormat.JPEG,40出);
        如果(b.com preSS(Bitmap.Com pressFormat.JPEG,40出)==真)
            out.close();
    }赶上(例外五){
        e.printStackTrace();
    }
}


解决方案

尝试一下本作将电缆带有电子邮件图像

获取图像从SD卡

 字符串路径= Environment.getExternalStorageDirectory()的toString()。
档案文件=新的文件(路径,YourImageName.JPEG);
乌里pngUri = Uri.fromFile(文件);

电子邮件意图

 意图emailIntent =新意图(android.content.Intent.ACTION_SEND);
emailIntent.setType(text / html的);
emailIntent.putExtra(android.content.Intent.EXTRA_STREAM,pngUri);

I have a bitmap that I have saved in the external storage. I already have a method that loads and returns the bitmap. My question is, how do I attach this image to an email Intent.

Note: I know how to start the email intent, I simply need to know how to attach the bitmap. Thanks.

This is how I am saving the pic:

private void savePicture(String filename, Bitmap b, Context ctx) {
    try {
        FileOutputStream out;
        out = ctx.openFileOutput(filename, Context.MODE_WORLD_READABLE);

        b.compress(Bitmap.CompressFormat.JPEG, 40, out);
        if (b.compress(Bitmap.CompressFormat.JPEG, 40, out) == true)
            out.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
解决方案

try this for Attach Image with Email

Fetch Image From SdCard

String path = Environment.getExternalStorageDirectory().toString();     
File file = new File(path,"YourImageName.JPEG");
Uri pngUri = Uri.fromFile(file);

Email Intent

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_STREAM, pngUri);

这篇关于如何安装位图到电子邮件的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 04:49