在android中发送附带图片的电子邮件(解决方案)

时间:2010-09-09 12:48:18

标签: android email android-emulator mms

图像存储在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[] {"abc@cde.com"});
    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();
}

            }                   

1 个答案:

答案 0 :(得分:0)

Ramesh - 我在你的例子中找到了价值,但也发现我没有必要拥有android.permission.SEND_SMS权限。

我想知道是否有必要 startActivity(Intent.createChooser(sendIntent,“Email:”));

指定“电子邮件:”。