光标提供的意图未正确触发(LiveFolders)

发布于 2024-08-29 04:22:54 字数 1567 浏览 3 评论 0原文

在我绝望地试图让 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 }

它似乎嵌入了我在实际触发的 Intentdata 部分中给出的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

甚是思念 2024-09-05 04:22:54

我也面临同样的情况;不幸的是,可以确认这一点:意图被包装到要触发的意图的数据部分中。

我想知道其他预定义的游标列是否被正确评估;我考虑过为要返回的案例自定义图标(每个条目,而不是所有条目)提交一个错误;但失败了。在整个网络中我没有找到任何成功使用这些专栏的例子或人;似乎只有名称和 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.

风吹短裙飘 2024-09-05 04:22:54

我也有类似的问题。我认为这是因为当 Cursor 将其数据发送到 fillWindow 中的 CursorWindow 时,它只能 putBlobputStringputLong 等。我不确定如何传递实际的 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 in fillWindow it can only putBlob, putString, putLong, etc. I'm not sure how an actual Bitmap 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...

心如狂蝶 2024-09-05 04:22:54

您可以尝试硬编码组件名称吗?

Intent intent = new Intent();
ComponentName comp = new ComponentName("com.google.android.browser",
                                   "com.google.android.browser.BrowserActivity");
intent.setComponent(comp);
intent.setAction("android.intent.action.VIEW");
intent.addCategory("android.intent.category.BROWSABLE");
Uri uri = Uri.parse(url);
intent.setData(uri); 

Can you try hardcoding component name.

Intent intent = new Intent();
ComponentName comp = new ComponentName("com.google.android.browser",
                                   "com.google.android.browser.BrowserActivity");
intent.setComponent(comp);
intent.setAction("android.intent.action.VIEW");
intent.addCategory("android.intent.category.BROWSABLE");
Uri uri = Uri.parse(url);
intent.setData(uri); 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文