出于某种原因,即使 Gmail 在其撰写屏幕中显示 PNG 附件,该附件也永远不会发送。对我来说我在这里做错了什么并不明显。
view.setDrawingCacheEnabled(true);
Bitmap b = view.getDrawingCache();
try {
boolean r = b.compress(CompressFormat.PNG, 95, new FileOutputStream(outputFile));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent.setType("image/png");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{emailTo});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailText);
Uri u = Uri.fromFile(outputFile);
emailIntent.putExtra(Intent.EXTRA_STREAM, u);
this.startActivityForResult(emailIntent, 0);