我是否被迫使用Android的notifyChange()方法?

发布于 2024-10-07 14:30:51 字数 123 浏览 0 评论 0原文

我是否被迫使用notifyChange()方法?我问这个问题是因为,当我调用此方法时,它会进入 onChange() 方法,但是当我不调用 notificationChange() 时,不会调用 onChange() 方法。为什么?

Am I forced to use the notifyChange() method? I ask this because, when I call this method it enters on the onChange() method, but when I don't call the notifyChange() the onChange() method is not called. Why?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

不顾 2024-10-14 14:30:51

好吧,

我不知道这是否是您问题的完整答案,但是从抽象类继承的任何内容 ContentObserver 应在实例化时调用其“onChange”。考虑到这一点,请查看您传递给 notificationChange 的 ContentObserver。首先,我会说一步一步地调试,并告诉我你会得到什么......

但是基于 源代码,看起来 ContentObserver 触发了 OnChange 并通过 notificationChange 方法“冒泡”。

因此,我能理解的最好的感觉是,既然 ContentObserver 的目的是“观察”或监听事件的触发(我认为又名意图;我仍在尝试获取 Android 术语),那么如果你想让你的观察者知道你的 onChange 正在发生,那么是的。但我想我需要更多关于你如何使用它的信息,以便给你一个更清晰的解释。

无论如何,如果我所说的话有任何错误,请有人纠正我,哈哈。

Okay here goes,

I don't know if this is a complete answer to your question but anything that inherits from the abstract class ContentObserver should call its "onChange" on instantiation. With that in mind take a look at the ContentObserver you are passing to your notifyChange. To start with I'd say debug step by step with that much in mind and tell me what you get...

But based on the source code, It looks as though ContentObserver fires the OnChange and that "bubbles up" through the the notifyChange method.

So with that the best sense I can make of it is that since the point of the ContentObserver is to "Observe" or listen for the firing of events (aka intents i think; I'm still trying to get the android lingo) then if you want your Observer to know your onChange is happening then yeah. But I think I would need more information about how your going about using it to give you a clearer explanation.

And by all means someone please set me straight if I'm at all wrong here in what I said lol.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文