You cannot tell which data element has changed.

SyncAdapters have a little more insight into what changed, the
IS_DIRTY flag on the raw contact.  SyncAdapters don't register
observers though - they are invoked by SyncManager.  Regular
applications should not use this flag, because the sync adapter that
owns the raw contact can reset that flag at an unpredictable moment,
including before the notification is delivered to observers.

So if you _really_ need to know which element changed, you will
probably need to maintain a copy on the application side.

Even if you could tell from the notification what specifically
changed, I would not recommend that design.  If it's just the display
that needs to be updated, having these detailed notifications would
probably complicate the logic unnecessarily.  If it's some persistent
storage that needs to be updated, using the notification would be an
even worse idea.  Notification delivery is not actually guaranteed:
you application could die for one reason or another before receiving
the notification.  For example, the system may run out memory and
choose to kill your app.

Cheers,
- Dmitri

On Fri, Dec 11, 2009 at 12:45 PM, Mo <[email protected]> wrote:
> Is there any additional logic that I can use once the observer is
> called to figure out what item in the DB changed?
>
>
> On Dec 11, 2:04 pm, Dmitri Plotnikov <[email protected]> wrote:
>> Hi Mo,
>>
>> No, sorry, there is no filtering mechanism.  It's not just
>> times_contacted. You will also get notifications when somebody's gtalk
>> status changes etc.  This notifications are only intended to serve as
>> a ping - basically telling observers that something changed. You
>> cannot use the notifications themselves to drive the application
>> logic.
>>
>> Cheers,
>> - Dmitri
>>
>> On Fri, Dec 11, 2009 at 11:44 AM, Mo <[email protected]> wrote:
>> > Thanks for the quick response Dimitri,
>> > But as I mentioned that in the DB there is a field for "contacted" (I
>> > guess how many times a contact is called" and "time contacted" (I am
>> > guessing the time stamp in msec when the contact was called). This
>> > would mean that my change observer would be called any time the user
>> > calls any of its contact.
>> > Is there a way in which I can filter only the events I am interested
>> > in namely on add/delete contact or contact name change.
>>
>> > Mo
>>
>> > On Dec 11, 1:38 pm, Dmitri Plotnikov <[email protected]> wrote:
>> >> Formally speaking, it is not really broken. The registerObserver API
>> >> only says that the notification will be delivered when the data
>> >> changes.  It does not say that the notification will NOT be delivered
>> >> when data does NOT change.
>>
>> >> In the new ContactsProvider we chose to keep the notification delivery
>> >> logic simple for now and send authority-level notifications only, so
>> >> it will send more notifications than strictly necessary.  This
>> >> behavior may change in the future.
>>
>> >> The good news is that we are NOT sending a notification for every
>> >> minor change.  We are sending one notification per transaction.  So
>> >> for instance, when a sync adapter adds 20 contacts in a batch, you
>> >> only get one notification.  The built-in Contacts app gives you an
>> >> example of an application that listens to notifications and refreshes
>> >> on every one.  Open Contacts.app during a sync. You will see how
>> >> contacts show up in batches - one batch per notification.  This should
>> >> not present a major problem unless you are running very expensive
>> >> queries.
>>
>> >> I hope this helps,
>> >> - Dmitri
>>
>> >> On Fri, Dec 11, 2009 at 11:02 AM, Mo <[email protected]> wrote:
>> >> > Hi Dimitry,
>> >> > Can you shed some light on this?
>>
>> >> > BR
>>
>> >> > On Dec 10, 9:00 pm, Mo <[email protected]> wrote:
>> >> >> Hi,
>> >> >> I was trying to register for any changes to the Contact.People DB as
>> >> >> follows:
>> >> >>        registerContentObserver(Contacts.People.CONTENT_URI, true, co);
>> >> >> And in my ContentObserver class I had the following:
>> >> >>              public void onChange(boolean change) {
>> >> >>                 Log.v( " Contact List updated" );
>> >> >>                 }
>>
>> >> >> This use to work in Cupcake and I use to get the call to "onChange"
>> >> >> only when a new contact was added, a contact was deleted or an
>> >> >> existing contact was modified. But in Eclair I keep on receiving
>> >> >> 'onChange" even after a call has been made to an existing contact (I
>> >> >> guess because of the "last_time_contacted " field in the DB).
>>
>> >> >> I tried registering for other DB (like "Data" and "Raw_Contacts") also
>> >> >> but experienced same issue.
>>
>> >> >> My question was that for Eclair is there a DB that I can register for
>> >> >> which will only be triggered if a new contact was added or old contact
>> >> >> was deleted or the contact name was modified?
>> >> >> Thanks
>>
>> >> > --
>> >> > You received this message because you are subscribed to the Google
>> >> > Groups "Android Developers" group.
>> >> > To post to this group, send email to [email protected]
>> >> > To unsubscribe from this group, send email to
>> >> > [email protected]
>> >> > For more options, visit this group at
>> >> >http://groups.google.com/group/android-developers?hl=en
>>
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Android Developers" group.
>> > To post to this group, send email to [email protected]
>> > To unsubscribe from this group, send email to
>> > [email protected]
>> > For more options, visit this group at
>> >http://groups.google.com/group/android-developers?hl=en
>>
>>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to