在android中发送带有附加图片的电子邮件(解决方案)
图像存储在android SD卡中
我得到了我们需要
<uses-permission android:name="android.permission.SEND_SMS"/>
在清单中指定的解决方案,工作代码是:
String _path = Environment.getExternalStorageDirectory() + "/mapp/test.jpeg";
File file = new File( _path );
Uri outputFileUri = Uri.fromFile( file );
if(file.exists())
{
//final ConnectivityManager connMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
//final int result = connMgr.startUsingNetworkFeature( ConnectivityManager.TYPE_MOBILE,Phone.FEATURE_ENABLE_MMS);
Toast.makeText(context,"exists",Toast.LENGTH_LONG).show();
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("image/jpeg");
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {"[email protected]"});
sendIntent.putExtra(Intent.EXTRA_SUBJECT,"World Toyata(via Android App");
sendIntent.putExtra(Intent.EXTRA_STREAM,outputFileUri);
sendIntent.putExtra(Intent.EXTRA_TEXT,"Problem Area Image");
startActivity(Intent.createChooser(sendIntent, ""));
}
else
{
Toast.makeText(context,"SD CARD Required ",Toast.LENGTH_LONG).show();
}
}
the image is stored in android sd card
I got the solution we need to specify
<uses-permission android:name="android.permission.SEND_SMS"/>
in manifest and the working code is:
String _path = Environment.getExternalStorageDirectory() + "/mapp/test.jpeg";
File file = new File( _path );
Uri outputFileUri = Uri.fromFile( file );
if(file.exists())
{
//final ConnectivityManager connMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
//final int result = connMgr.startUsingNetworkFeature( ConnectivityManager.TYPE_MOBILE,Phone.FEATURE_ENABLE_MMS);
Toast.makeText(context,"exists",Toast.LENGTH_LONG).show();
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("image/jpeg");
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {"[email protected]"});
sendIntent.putExtra(Intent.EXTRA_SUBJECT,"World Toyata(via Android App");
sendIntent.putExtra(Intent.EXTRA_STREAM,outputFileUri);
sendIntent.putExtra(Intent.EXTRA_TEXT,"Problem Area Image");
startActivity(Intent.createChooser(sendIntent, ""));
}
else
{
Toast.makeText(context,"SD CARD Required ",Toast.LENGTH_LONG).show();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Ramesh - 我在您的示例中发现了价值,但也发现我没有必要拥有 android.permission.SEND_SMS 权限。
我想知道是否有必要
startActivity(Intent.createChooser(sendIntent, "电子邮件:"));
您在其中指定“电子邮件:”。
Ramesh - I found value in your example but also found that it is was not necessary for me to have the permission android.permission.SEND_SMS.
I am wondering if it is necessary to have
startActivity(Intent.createChooser(sendIntent, "Email:"));
where you specify "Email:".