代码之家  ›  专栏  ›  技术社区  ›  Felix

游标提供的意图未正确激发(livefolders)

  •  3
  • Felix  · 技术社区  · 15 年前

    为了让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 实际发射的部分 意图 是的。为什么要这么做?我真的开始相信这是一个平台缺陷。


    更新: 我已经申请了 an issue 并删除了livefolders功能。我会在我的应用程序中包括它,当我在这里或那里得到一个答复,澄清这件事。如果我有时间,我想我会上传一个演示应用到这个问题。


    更新: 我收到通知说赏金三天后到期。没人想要?:)


    2010年4月25日更新: 我已经更新了 the issue 并上传了一个测试应用程序。如果有人能在设备上测试这个应用程序,那就太好了,也许这是一个很微妙的问题,它只出现在模拟器上。

    3 回复  |  直到 15 年前
        1
  •  1
  •   Flo    15 年前

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

    我想知道是否对其他预定义的光标列进行了正确的计算;我考虑过为要返回的case自定义图标(每个条目,不是所有条目都有一个)提交一个bug;但是失败了。在整个网络中,我没有找到任何成功使用这些列的示例或人员;只有name和id似乎起作用。

    这是android的主要usp特性之一,看起来它只是没有被普遍接受。

        2
  •  1
  •   Mats Rietdijk Maurice    12 年前

    我也有类似的问题。我认为这是因为当光标将数据发送到 CursorWindow 在里面 fillWindow 它只能 putBlob 我是说, putString 我是说, putLong 等等,我不确定 Bitmap 可以传递对象(图标位图)或意图对象(意图)。女家长会做一个 .toString() 在任何物体上。在一个意图对象上是这样的:“ Intent { act=android.intent.action.EDIT dat=URI } “。我认为系统没有正确地将其解释回正确的uri。

    我试着把意图连载成 脓包 ,但意图不可序列化。我要做的只是将uri作为intent字段传递。这只为您提供特定uri的默认操作,但可以工作。我也有一个问题,如果我指定 null “对于意图,它也会出错,即使我指定了一个额外的实时文件夹。如果在光标中根本不指定字段,则基本意图有效,但如果将字段指定为空,则失败。它似乎没有回到基本意图。

    希望这有帮助…

        3
  •  0
  •   Vinay    15 年前

    你能试试硬编码组件名吗?

    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);