如何在Android中将图片从Drawable附加到MMS? [英] How to attach image to MMS from Drawable in Android?

查看:145
本文介绍了如何在Android中将图片从Drawable附加到MMS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将资源/可绘制文件夹中的图像附加到MMS.是否可以将可绘制文件夹中的图像附加到MMS.如果是,请在此处提供一些代码.我尝试了很多,也在这里找到了很多以及在Google上的浏览器,但仍无法获得正确的解决方案.请为我解决此问题.感谢Advance.我的代码如下:

I want to attach image from resource/drawable folder to MMS.Is it possible to attach image from drawable folder to MMS.if yes then please provide me some code here.I tried a lot and also found a lot here on So as well as on Google but still not able to get the right solution yet.Please some one help me for my this issue.Thanks in Advance.My code is as:

Intent sendIntent = new Intent(Intent.ACTION_SEND);
        sendIntent.setType("image/png");
        sendIntent.putExtra("sms_body",
                getResources().getText(R.string.Message));

        File f = new File(Environment.getExternalStorageDirectory()
                .getAbsolutePath(), "koala.jpg");

        Uri uri = Uri.fromFile(f);
        sendIntent.putExtra(Intent.EXTRA_STREAM, uri);

        startActivity(Intent.createChooser(sendIntent, ""));

推荐答案

您可以通过以下步骤实现此目标

You can achive this in following steps

首先从您的可绘制中获取图像的位图

First get the bitmap of image from your drawable

然后将该位图保存到 SD卡

然后将sdCard文件路径提供给您sendIntent

Then give that sdCard file path to you sendIntent

这篇关于如何在Android中将图片从Drawable附加到MMS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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