@Overridepublic void onContentChanged() { if (!mCursor.isClosed()) { deliverResult(mCursor); } forceLoad();}
而CursorLoader默认的onContentChanged的实现是不立即更新:
public void onContentChanged() { if (mStarted) { forceLoad(); } else { // This loader has been stopped, so we don't want to load // new data right now... but keep track of it changing to // refresh later if we start again. mContentChanged = true; }}一旦一次load完成,在onLoadFinished时就会更新界面了。
实验很简单,开两个模拟器,在第一个模拟器(5554)上运行例子,不要离开页面,让后从5556向5554发短信,就能看到实时更新界面上显示的数据了。