Frage

I've been able to successfully register an ContentObserver against a ContentProvider (in my case the ContactsProvider), and successfully requery when changes happen.

But if my app is watching the contacts and the contacts app is doing an import, multiple overlapping onChange calls are triggered.

What's the correct way to handle this?

My initial thoughts is to set a flag if in middle of a query, and count the number of calls. If at the end of async query, the count is non-zero, just query again. But I'm not sure that I'm not going to miss something, or trigger too many calls.

Any suggestions?

War es hilfreich?

Lösung

That sounds workable, assuming you are doing the queries in a background thread to avoid slowing down the main UI thread.

A standardized way of doing this sort of thing is with a Loader. There is a nice series of articles describing this relatively new approach in more detail and why it was invented.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top