Wednesday, April 3, 2013

[android-developers] reusing AsyncTaskLoader with always fresh data

Hello,


I wont to reuse my AsyncTaskLoader. To do it I call:

Loader<Result> loader = getLoaderManager().initLoader(0, args, this);
loader.startLoading();

In this startLoading method is a if-statment:

if (info.mHaveData && mStarted) {
// If the loader has already generated its data, report it now.
info.callOnLoadFinished(info.mLoader, info.mData);
}
(http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.2.2_r1/android/app/LoaderManager.java#616)


The mStarted flag indicate that the LoaderManager of the activity is
started.

And the info.mHaveData flag indicate that the loader has data or not
from a previous run.

My problem / question: How can I reset the loader after a previous run
that it lose its data and info.mHaveData is false? Because I get the
onLoadFinished call twice and the first one is wrong :-(


Ralph

--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
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 unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment