It seems, my ContentObserver does not tell me if data are changed by a
different process? Or maybe I'm doing something wrong:
I have an activity in which I register a ContentObserver:
----------------------------
mCursorListFilter = getContentResolver().query(Lists.CONTENT_URI,
myFilter,
null, null, Lists.DEFAULT_SORT_ORDER);
startManagingCursor(mCursorListFilter);
class mListContentObserver extends ContentObserver {
public mListContentObserver(Handler handler) {
super(handler);
}
@Override
public void onChange(boolean arg0) {
Log.i(TAG, "mListContentObserver: onChange");
mCursorListFilter.requery();
super.onChange(arg0);
}
};
mCursorListFilter.registerContentObserver(new
mListContentObserver(new Handler()));
----------------------------
I do receive the LogCat events onChange if data are changed from
within the same activity.
However, when I change the data through a separate IntentReceiver that
receives Intents in the background, I don't receive onChange events,
and my data in my ListViews don't get updated.
In the IntentReceiver I do something like this:
----------------------------
public void onReceiveIntent(Context context, Intent intent) {
[...]
Cursor c = mContentResolver.query(
Shopping.Lists.CONTENT_URI,
mProjectionLists,
Shopping.Lists.SHARE_NAME + " = '" + shareListName +
"'",
null,
Shopping.Lists.DEFAULT_SORT_ORDER);
[...]
c.first();
c.updateString(mProjectionListsSHARECONTACTS, shareContacts);
c.commitUpdates();
c.requery();
}
----------------------------
The data are changed in the database. If I exit my activity and start
it again, I see the new data. Just they don't get updated "live" while
the IntentReceiver receives the data in the background.
Is a ContentObserver suitable for these cases, or is it only made to
notify within one activity? Should I use other methods so that the
IntentReceiver can notify the main Activity (if running)?
Peli
--~--~---------~--~----~------------~-------~--~----~
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]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---