3

在我试图让 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;
}

在所有正常情况下,单击 LiveFolder 中的项目时,它应该启动浏览器并显示 Google 主页。但事实并非如此。它给出了一个Application is not installed on your phone错误。不,我没有为我的 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 项目的问题并上传了一个测试应用程序。如果有人可以在设备上测试这个应用程序会很好,也许这是一个非常微妙的问题,它只出现在模拟器上。

4

3 回答 3

1

我也有类似的问题。我认为这是因为当光标将其数据发送到其中CursorWindow时,fillWindow它只能putBlob, putString,putLong等。我不确定如何传递实际Bitmap对象 (ICON_BITMAP) 或意图对象 (INTENT)。MatrixCursor 将对.toString()任何对象执行 a。在 Intent 对象上将类似于:“ Intent { act=android.intent.action.EDIT dat=URI }”。我认为系统没有正确地将其解释回正确的 URI。

我尝试将意图序列化为putBlob,但 Intent 不可序列化。我所做的只是将 URI 作为 Intent 字段传递。这只会为您提供对特定 URI 的默认操作,但有效。我也有一个问题,如果我null为 Intent 指定“”,它也会出错,即使我指定了 EXTRA_LIVE_FOLDER_BASE_INTENT。如果我根本没有在游标中指定该字段,则基本意图有效,但如果我将该字段指定为 null,它将失败。它似乎没有回到基本意图。

希望这可以帮助...

于 2011-09-16T03:46:34.683 回答
1

我也面临同样的问题;并且可以不幸地确认它:意图被包装到要触发的意图的数据部分中。

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

这是 Android 的主要 USP 功能之一,看起来它只是未能被普遍接受。

于 2010-06-03T22:14:39.323 回答
0

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

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); 
于 2010-04-25T06:48:35.487 回答