转发意图?
例如,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 应用程序是可选择的或启动的:-(
还有一个问题 - cmp 是什么意思?我如何将此信息设置为新意图?
我希望解决这个问题,因为保存内容真的很烦人并使用文件浏览器启动它
并祝愿
nauni 。
for example k9-Mail will try to find a application to handle some attachments and uses the MimeType-Specification of the email.
For example with PDF it sends correct (debugging information):
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
But if the mail attach the PDF not with MimeType "application/pdf" but with "'application/pdf'" it does not work. :-( This results in the broadcast:
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
The ' at beginning and end causes IMHO that no application is found to handle that. :-(
K9-Mail miss some other mappings to, so my idea was to build a little application, that catch the call and forward it. But for example the reader is not opened. I tried that:
@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");
}
I think something with "cmd" is wrong ... because the debugger shows
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 }
Can someone help me? Is it possible, that the PDF-application can't get the content? But I can't see that the PDF-application is selectable or startet. :-(
One question is also - what means cmp? And how can I set this information to the new intent?
I hope to solve this problem, because it is really annoying to save the content and start it with file browser.
tia and reagards
nauni
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
现在我看到了我的错误...尝试了这么多之后我盲目了...
确实记录了错误的对象:-( ...
做了正确的记录,所以我发现了问题,现在应用程序尝试启动 acrorad。所以这个问题已经解决了。谢谢!
是用一个命令设置数据和类型,然后设置第一个命令,然后使用下一个命令将没有成功。
问题 nauni
PS:但现在我遇到安全权限问题......但首先我尝试找到一个解决方案,在我问问题之前;-)
Now I saw my mistake ... I was blind after trying so much ...
did log the wrong object :-( ...
did the right logging, so I found the problem and now the application try to start the acrorad. So this problem is solved. Thanks!
The problem was to set the data and type with one command. So both is set correct and start the application. Set first one and with the next command the next will have no success.
Thanks for your attention, nauni
PS: But now I have a Problem with security permission ... but first I try to find a solution, before I ask something. ;-)