I load a list of some data. I do it in AsyncTask and I also use lastNonConfigurationInstance, so when I change the configuration of a device, list is not loaded again. Everything is clear here.
BUT when I click on an item, the “extended” data of this item is loaded. And here I’m not sure what to do… Should I use another AsyncTask for downloading data of the item or just do it directly in onItemClick()? If I put it in AsyncTask I should also remember about configuration change and in this case I should also use lastNonConfigurationInstance?
Thanks in advance for all your suggestions, answers…
I load a list of some data. I do it in AsyncTask and I
Share
If you “extended” data taken more than 20ms to fetch, you should consider using AsyncTask for this too.
If your data is quick to fetch, you don’t need
lastNonConfigurationInstance. Seems like you could just save you “current index” of the item the user clicked on in theonSaveInstanceData. When your activity is recreated inonCreate(Bundle)read the selected index from the bundle and load data for the sub item.If your extended data takes time, then you could use the
lastNonConfigurationInstancemechanism to save data for the currently selected item.