首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为什么通知URI不适用于MergeCursor?

为什么通知URI不适用于MergeCursor?
EN

Stack Overflow用户
提问于 2013-03-20 21:28:44
回答 1查看 429关注 0票数 2

假设您的ContentProvider中有一个CONTENT_URI,您希望在其中执行一些复杂的操作,并返回一个组合的游标(MergeCursor),而不是一个简单的Cursor

碰巧的是,如果您在MergeCursor上设置通知URI,而不是在该MergeCursor中设置光标,则通知将无法工作。

初始代码:

代码语言:javascript
运行
复制
            Cursor[] cursors = { extraCursorBefore, usersCursor, extraCursorAfter };
            Cursor extendedCursor = new MergeCursor(cursors);
            // Make sure that potential listeners are getting notified
            extendedCursor.setNotificationUri(getContext().getContentResolver(), CONTENT_URI_PEOPLE);
            return extendedCursor;

PS:如果有人以任何方式有了另一个想法,或者想知道为什么这个地狱不能在最初的MergeCursor上工作,那么请分享你的知识。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-03-20 21:28:44

因此,您需要在Cursor上从生成的MergeCursor中设置通知URI

实际工作的代码:

代码语言:javascript
运行
复制
            Cursor[] cursors = { extraCursorBefore, usersCursor, extraCursorAfter };
            Cursor extendedCursor = new MergeCursor(cursors);
            // Make sure that potential listeners are getting notified
            usersCursor.setNotificationUri(getContext().getContentResolver(), CONTENT_URI_PEOPLE);
            return extendedCursor;
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15524952

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档