2012-04-12 37 views
4

我试图使一个应用程序来捕捉图像,并通过电子邮件发送,我成功地用它下面的代码通过电子邮件发送图像,Android?

String path = Images.Media.insertImage(getContentResolver(), bmp,"title", null); 
    Uri screenshotUri = Uri.parse(path); 
    Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
    emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
    emailIntent 
      .putExtra(android.content.Intent.EXTRA_EMAIL, emailAddresses); 
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); 
    emailIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri); 
    emailIntent.setType("image/png"); 
    startActivity(Intent.createChooser(emailIntent, "Send email using")); 

,但图像在一个小尺寸发送和非常低的分辨率?!任何建议发送图像的实际大小和分辨率?!或者有没有其他方法可以从相机结果中获取JPEG图像而不是位图?

在此先感谢

+0

http://stackoverflow.com/questions/2518055/image-attachment-to-a-mail-how-in-android – waqaslam 2012-04-12 13:10:49

回答

0
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
emailIntent.setType("plain/text"); 
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, EMAIL_SUBJECT); 
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, EMAIL_TEXT); 
File newFile = new File(Environment.getExternalStorageDirectory(), IMAGE_PATH); 
emailIntent.putExtra(android.content.Intent.EXTRA_STREAM,Uri.fromFile(newFile)); 
startActivity(emailIntent); 
+0

什么是IMAGE_PATH?! – hatemfaheem 2012-04-12 14:07:11

+0

图像的路径,因为流采用文件路径的URI – Basbous 2012-04-12 22:57:47