我在android上工作,試圖發送帶有附加文件的電子郵件,但出現以下錯誤。將PDF文件附加到應用程序的電子郵件
android.content.ActivityNotFoundException:無活動處理 意向{行動= android.intent.action.SENDTO DAT =文件://assets/Cards/myfile.pdf典型值=應用程序/ PDF FLG = 0x10000000的 (有演員)}
林Android開發人員因此Im有點兒丟失什麼,我需要做的非常新。以下是我目前正在嘗試的內容
Intent intent = new Intent(Intent.ACTION_SENDTO); // it's not ACTION_SEND
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "Card Set "));
intent.putExtra(Intent.EXTRA_TEXT, "");
intent.setData(Uri.parse("mailto:"));
intent.setDataAndType(Uri.parse("file://assets/Cards/" + "myfile.pdf"),
"Applications/pdf");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
activity.startActivity(intent);
我可以在不附加文件的情況下正常創建和發送電子郵件。我如何應安裝文件中的任何幫助,正確地將是巨大的感謝
在真正的設備NOT IN EMULATOR測試它。如果這沒有幫助,然後嘗試設置intent.setType(「application/pdf」);並看到結果。 –
是啊我一直在設備上測試,並嘗試設置應用程序/ pdf,但它給了我相同的錯誤 – glogic
嘗試設置您的意圖Intent.ACTION_SEND。正確的PDF文件的MIME類型是「application/pdf」而不是「Applications/pdf」 –