由於某些原因,即使Gmail在其撰寫屏幕中顯示PNG附件,也永遠不會發送附件。對我來說不明顯,我在這裏做錯了什麼。無法通過我的應用程序向Gmail發送圖像附件
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);