2013-02-23 71 views
0

我通過這個代碼發送原木結果的郵件:的Android AVD郵件應用程序沒有發送出附件

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE); 
    emailIntent.setType("text/plain"); 
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, emailAddressList); 
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Android Log"); 
    emailIntent.putParcelableArrayListExtra(android.content.Intent.EXTRA_STREAM, uris); 
    try { 
     startActivity(Intent.createChooser(emailIntent,"Send...")); 
     finish(); 
    } 
    catch (android.content.ActivityNotFoundException e) { 
     new AlertDialog.Builder(SendActivity.this) 
     .setIconAttribute(android.R.attr.alertDialogIcon) 
     .setTitle(R.string.cannotSend) 
     .setMessage(R.string.appNotFound) 
     .setPositiveButton(R.string.ok, null) 
     .show(); 
    } 

在模擬器(trget Jelly Bean)的電子郵件應用程序,這是一個:

enter image description here

當發送它示出了本,其具有目的地,主體和附件:

enter image description here

的oubox顯示郵件帶有附件:

enter image description here

但收到的消息沒有attachmetns AR所有:

enter image description here

我唯一的猜測是,電子郵件應用程序失敗,但我不知道這是否是我的錯,如果我能糾正它,或者如果有另一個郵件客戶端,我可以安裝在AVD中來完成這項工作。 PS:順便說一句,發送這些郵件在AVD上真的很慢,當我測試撰寫和發送文本郵件時,它的發送速度要快得多。

編輯
我有一個想法,會不會是因爲附着物從臨時文件的問題引起的?他們被鏈接到郵件而不是被複制,到電子郵件應用程序發送它們時,它們不再存在?

attachment = File.createTempFile("logs", "txt"); 
out = new FileOutputStream(attachment); 
out.write(logs.getBytes()); 
out.close(); 
uris.add(Uri.fromFile(attachment)); 

attachment = File.createTempFile("sysinfo", "txt"); 
out = new FileOutputStream(attachment); 
out.write(getSystemInfo()); 
out.close(); 
uris.add(Uri.fromFile(attachment)); 

回答

0

那麼,這絕對是一個模擬器問題。

我安裝了intel的HAXM虛擬機,並創建了一個新的AVD與英特爾映像,不僅運行速度更快,而且它發送郵件,附件包括,沒有問題立即。

編輯
我發現,當它是一個真正的問題在真實設備上進行測試,this post is very helpful

相關問題