例如,k9-Mail 将尝试找到一个应用程序来处理一些附件并使用电子邮件的 MimeType-Specification。
例如,对于 PDF,它会发送正确的(调试信息):
12-27 15:41:58.992: I/ActivityManager(119): Starting: Intent { act=android.intent.action.VIEW dat=content://com.fsck.k9.attachmentprovider/01549957-459d-4ee3-b568-7e59390a9535/3/VIEW typ=application/pdf flg=0x3880001 cmp=com.adobe.reader/.AdobeReader } from pid 119
但是,如果邮件附加的 PDF 不是 MimeType "application/pdf" 而是 "'application/pdf'" 它不起作用。:-( 这导致广播:
12-27 15:35:15.007: I/ActivityManager(119): Starting: Intent { act=android.intent.action.VIEW dat=content://com.fsck.k9.attachmentprovider/01549957-459d-4ee3-b568-7e59390a9535/2/VIEW typ='application/pdf' flg=0x80001 } from pid 3635
' 在开头和结尾会导致恕我直言,找不到应用程序来处理它。:-(
K9-Mail 错过了其他一些映射,所以我的想法是构建一个小应用程序,它可以捕获呼叫并转发它。但是例如没有打开阅读器。我试过了:
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
Log.i(TAG, "Activity is called and created");
mapping.put("'application/pdf'", "application/pdf");
String type = getIntent().getType();
if (mapping.containsKey(type)) {
Log.i(TAG, "found mapping: " + type + " => " + mapping.get(type));
Log.v(TAG, "Intent before: " + getIntent().toString());
Intent i = new Intent(getIntent().getAction(), getIntent().getData());
i.setType(mapping.get(type));
i.setData(getIntent().getData());
i.setFlags(getIntent().getFlags());
Log.v(TAG, "Intent after: " + getIntent().toString());
startActivity(i);
}
finish();
}
@Override
protected void onDestroy() {
super.onDestroy();
Log.i(TAG, "Activity is destroyed");
}
我认为带有“cmd”的东西是错误的......因为调试器显示
12-28 08:38:51.445: V/ActivityForwardIntent(1195): Intent after: Intent { act=android.intent.action.VIEW dat=content://com.fsck.k9.attachmentprovider/01549957-459d-4ee3-b568-7e59390a9535/2/VIEW typ='application/pdf' flg=0x80001 cmp=de.blablupp.android.testproject/.ActivityForwardIntent }
有人能帮我吗?PDF应用程序是否有可能无法获取内容?但我看不到 PDF 应用程序是可选择的或启动的。:-(
一个问题也是 - cmp 是什么意思?以及如何将此信息设置为新意图?
我希望解决这个问题,因为保存内容并使用文件浏览器启动它真的很烦人。
tia 和问候
瑙尼