Thursday, March 22, 2012

[android-developers] Loader Manager behaviour problem

Hi,
Please help me on this.

I have my own class similar to CursorLoader which extends AsyncTaskLoader.

I need to do multiple queries to network so I am using LoaderManager
callbacks. I do not use ForceLoadContentObserver in my implementation,
instead i use normal ContentObserver.

1. I do a initLoader with say id loader id 1., initially i get a
cursor with empty count in onLoadFinished() but since i also register
on content observer, onLoadFinished() gets hit again with some data
and its displayed on UI.

2. Now when i need to refresh my data on listview through some button,
i destroy my loader with id 1 and create a new loader with id 2 (new
instance of my customized Cursor loader class gets created) and
control hits again on onLoadFinished() with some data. Now in mean
while my content observer also gets hit as fresh data is fetched from
network but when i check isStarted() function of Loader to decide
whether to call forceLoad or not, it returns false, also i printed
isReset() function as false, which means that Loader is reset by the
time Content observer got hit.

Why is it so? How it is diffrent from the first case when i started
loader with id 1.

In second case i just destroyed the loader with id1 and did initloader
with id 2.

Also i tried in second case that if i did a restart on loader id 1
instead of destroying, then also when my content observer gets hit i
see isStarted() as false.

Due to this I am not able to pass the new/refreshed data to my app.

Please can anybody help me in understanding this or is this a LoaderManager bug.

Thanks & Regards,
Sudeep.

--
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

No comments:

Post a Comment