0
A
回答
0
你可以嘗試這樣的事情連着你要處理的Intent
活動。 AFAIK,處理特定文件擴展名的唯一方法是使用pathPattern
,因爲我不相信您可以保證郵件應用程序將如何設置他們無法識別的文件的MIME類型。
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" />
<data android:pathPattern=".*\\.shtml" />
</intent-filter>
與AOSP捆綁的電子郵件應用程序的推斷從附加文件的MIME類型,因此,如果它不能找到一個在靜態地圖,它將使用application/xxx
,所以你也可以嘗試
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" />
<data android:mimeType="application/shtml" />
</intent-filter>
如果郵件應用使用不同的格式(如content://),則兩種情況下的scheme屬性可能都是不必要的或阻礙的,所以如果不起作用,請嘗試省略該部分。
HTH
0
這是我從電子郵件獲取附件的最新版本。如果你使用它,如果你的源代碼保存了我的名字,它會很酷。
if (intentaction != null) {
if (intentaction.equals("android.intent.action.VIEW")) {
Uri data = intent.getData();
Uri u;
if (data != null) {
try {
pathname = data.getPath();
File f = new File(pathname);
boolean b = f.exists();
if (!b) {
pathname = null;
}
} catch (Exception e) {
pathname = null;
}
if (pathname == null) {
try {
is = new BufferedInputStream(getContentResolver()
.openInputStream(data));
_is = new BufferedInputStream(getContentResolver()
.openInputStream(data));
// _savefile = true;
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Cursor c = getContentResolver().query(data, null, null,
null, null);
if (c != null) {
c.moveToFirst();
int fileNameColumnId = c
.getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME);
if (fileNameColumnId >= 0) {
_previewFileName = c
.getString(fileNameColumnId);
}
if (_previewFileName == null) {
fileNameColumnId = c
.getColumnIndex(MediaStore.MediaColumns.DATA);
if (fileNameColumnId >= 0) {
pathname = c.getString(fileNameColumnId);
File f = new File(pathname);
boolean b = f.exists();
if (b) {
try {
if (is != null) {
is.close();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
is = null;
try {
if (_is != null) {
_is.close();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
_is = null;
} else {
pathname = null;
}
}
}
}
}
}
}
}
// If we have an attachment
if (is != null) {
k = new KmlSummary(is);
} else if (pathname != null) {
k = new KmlSummary(pathname);
好運
相關問題
- 1. 通過管道電子郵件保存電子郵件附件
- 2. 帶附件的公開電子郵件
- 3. Applescript - 拖放文件附件以打開新電子郵件
- 4. Android:如何使用intent-filter處理PDF電子郵件附件?
- 5. 電子郵件附件通過mime4j
- 6. PHP電子郵件附件不通過
- 7. 使用clickonce和文件關聯從Outlook電子郵件打開文件附件
- 8. Android - 用附件提示打開電子郵件意向
- 9. 如何打開默認的電子郵件客戶端附件
- 10. 文件附加到電子郵件 - 我試圖打開MYAPP
- 11. 在Android中打開電子郵件附件
- 12. 電子郵件附件在應用程序中打開?
- 13. Javascript:打開Outlook並將附件添加到新電子郵件
- 14. 打開帶附件的電子郵件客戶端
- 15. 黑莓:Office附件可以從電子郵件打開,但不能從瀏覽器打開
- 16. 電子郵件附件到服務器
- 17. 電子郵件附件
- 18. PHP電子郵件附件
- 19. 電子郵件附件
- 20. 電子郵件附件
- 21. Powershell電子郵件附件
- 22. 電子郵件附件
- 23. 電子郵件附件?
- 24. 從電子郵件下載附件
- 25. 如何將電子郵件過濾器添加到IMAP電子郵件帳戶?
- 26. 電子郵件Intent.EXTRA_SUBJECT無法更改Intent
- 27. 以編程方式從POP3打開電子郵件並提取附件
- 28. 如何從android應用程序發送/打開電子郵件附件?
- 29. Zend_Mail - 閱讀電子郵件附件 - 彈回過大的電子郵件
- 30. 根據電子郵件主題保存電子郵件附件