光标提供的意图未正确触发(LiveFolders)
在我绝望地试图让 LiveFolders 工作时,我在我的 LiveFolder
ContentProvider
中尝试了以下操作:
public Cursor query(Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
MatrixCursor mc = new MatrixCursor(new String[] { LiveFolders._ID, LiveFolders.NAME, LiveFolders.INTENT } );
Intent i = null;
for (int j=0; j < 5; j++) {
i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com/"));
mc.addRow(new Object[] { j, "hello", i} );
}
return mc;
}
在正常情况下,应该启动浏览器并在以下情况下显示 Google 主页:单击 LiveFolder 中的项目。但事实并非如此。它给出了您的手机上未安装应用程序
错误。不,我没有为我的 LiveFolder 定义基本意图。
logcat
说:
I/ActivityManager( 74): Starting activity: Intent { act=android.intent.action.VIEW dat=Intent { act=android.intent.action.VIEW dat=http://www.google.com/ } flg=0x10000000 }
它似乎嵌入了我在实际触发的 Intent
的 data
部分中给出的 Intent
。它为什么要这样做?我真的开始相信这是一个平台错误。
更新:我已提交问题 并删除了 LiveFolders 功能。当我在这里或那里得到澄清这件事的答复时,我会将其包含在我的应用程序中。如果我有时间,我想我会针对该问题上传一个演示应用程序。
更新:我收到一条通知,称赏金将在 3 天后到期。没人想要吗? :)
2010 年 4 月 25 日更新:我已更新Android 项目上的问题并上传了测试应用程序。如果有人可以在设备上测试这个应用程序,那就太好了,也许这是一个非常微妙的问题,它只出现在模拟器上。
In my desperation with trying to get LiveFolders working, I have tried the following in my LiveFolder
ContentProvider
:
public Cursor query(Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder) {
MatrixCursor mc = new MatrixCursor(new String[] { LiveFolders._ID, LiveFolders.NAME, LiveFolders.INTENT } );
Intent i = null;
for (int j=0; j < 5; j++) {
i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com/"));
mc.addRow(new Object[] { j, "hello", i} );
}
return mc;
}
Which, in all normalness, should launch the Browser and display the Google homepage when clicking on an item in the LiveFolder. But it doesn't. It gives a Application is not installed on your phone
error. No, I'm not defining a base intent for my LiveFolder.
logcat
says:
I/ActivityManager( 74): Starting activity: Intent { act=android.intent.action.VIEW dat=Intent { act=android.intent.action.VIEW dat=http://www.google.com/ } flg=0x10000000 }
It seems it embeds the Intent
I give it in the data
section of the actually fired Intent
. Why is it doing this? I'm really starting to believe it's a platform bug.
Update: I have filed an issue and removed the LiveFolders feature. I will include it in my app when I'll get a response either here or there that clarifies this thing. If I get the time I think I'll upload a demo app to that issue.
Update: I have received a notification that the bounty is expiring in 3 days. No one wants it? :)
Update 04/25/2010: I have updated the issue on the Android project and uploaded a test application. It would be nice if someone could test this application on a device, maybe it's such a subtle problem that it only appears on the emulator.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我也面临同样的情况;不幸的是,可以确认这一点:意图被包装到要触发的意图的数据部分中。
我想知道其他预定义的游标列是否被正确评估;我考虑过为要返回的案例自定义图标(每个条目,而不是所有条目)提交一个错误;但失败了。在整个网络中我没有找到任何成功使用这些专栏的例子或人;似乎只有名称和 ID 有效。
这是 Android 的主要 USP 功能之一,但看起来它并没有被普遍接受。
I face the same; and can unfortunately confirm it: The intent is wrapped into the data part of the intent to be fired.
I an wondering if the other predefined CURSOR-columns are evaluated correctly; I thought about filing a bug for the case custom icons (per entry, not one for all of them) are to be returned; but failed. In the whole web I did not find any example or person who were successfull using these columns; only name and id seem to work.
This is one of the main USP features of Android, and it looks like it just failed to be accepted commonly.
我也有类似的问题。我认为这是因为当 Cursor 将其数据发送到
fillWindow
中的CursorWindow
时,它只能putBlob
、putString
、putLong
等。我不确定如何传递实际的Bitmap
对象(ICON_BITMAP)或 Intent 对象(INTENT)。 MatrixCursor 将对任何对象执行.toString()
。在 Intent 对象上,类似于:“Intent { act=android.intent.action.EDIT dat=URI }
”。我认为系统没有正确地将其解释回正确的 URI。我尝试将 Intent 序列化为
putBlob
,但 Intent 不可序列化。我要做的只是将 URI 作为 Intent 字段传递。这只会为您提供针对特定 URI 的默认操作,但确实有效。我还遇到这样的问题:如果我为 Intent 指定“null
”,即使我指定了 EXTRA_LIVE_FOLDER_BASE_INTENT,它也会出错。如果我根本没有在光标中指定该字段,则基本意图有效,但如果我将该字段指定为空,则它将失败。它似乎并没有回到基本意图。希望这有帮助...
I'm having a similar issue as well. I think it is because when the Cursor sends it's data to
CursorWindow
infillWindow
it can onlyputBlob
,putString
,putLong
, etc. I'm not sure how an actualBitmap
object (ICON_BITMAP) or Intent object (INTENT) can be passed. The MatrixCursor will do a.toString()
on any object. On an Intent object would be something like: "Intent { act=android.intent.action.EDIT dat=URI }
". I don't think the system is correctly interpreting this back to the proper URI.I've tried serializing the intent into
putBlob
, but Intent isn't serializable. What I have gotten to work is simply passing a URI as the Intent field. This only gives you the default action on a particular URI, but works. I'm also having the problem where if I specify "null
" for the Intent it errors as well, even if I specify a EXTRA_LIVE_FOLDER_BASE_INTENT. If I don't specify the field at all in the cursor the base intent works, but if I specify the field as null it fails. It doesn't appear to fall back to the base intent.Hope this helps...
您可以尝试硬编码组件名称吗?
Can you try hardcoding component name.