question

bitdeveloper avatar image
bitdeveloper asked

Weird issue when loading data using an AsyncTask

So I'm porting my Android app over to Kindle, and expected some tweaks for compatibility, but this is getting ridiculous. I have an activity which loads data from the web using an AsyncTask. Pretty straightforward, at least on regular Android devices. Just load the data in doInBackground, then in onPostExecute (the UI thread) apply the data to the UI to build the page. However it seems that in some cases (not all) the data from the AsyncTask won't display on screen. for instance, some data is displayed in a GridView. I update the GridView adapter, use the adapter's notifyDataSetChanged() method, and what should happen is that the view is changed to display the data from the adapter. This process on a normal Android device works fine. On this Kindle however the data doesn't load (again in some cases, not all, which makes this even more frustrating). I've found that if you press the Back button on the Kindle, then drag your finger off of it (so finish() isn't called), the data will sometimes show up! I get the feeling the normal behavior of notifyDataSetChanged() has been altered for Kindle's version of Android, but I'm not sure what else I'm expected to do to show data loaded into an adapter. Has anyone run into this issue? Also, I should note in the case of it only happening sometimes, the actual data structure remains constant, but for certain pages it works and others it does not (the app pertains to music, so for example one artist's page loads properly while the other's does not). Thanks!
fire tablet
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Bitdeveloper, Could you create a sample app just to demonstrate the issue and send us it me? I am sending a mail to you from my email id so that you can attach it and send me back. You can send your existing app also if there is no issue. Or just a sample app having a grid view with the data load (async task) and render functionality that some times fails to render in Kindles but not on Generic Android devices.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

bitdeveloper avatar image
bitdeveloper answered
I was able to find a solution to the problem. My app utilized the XML layout attribute android:animateLayoutChanges in many different layouts. Apparently there is a problem on Kindle OS with using this attribute in both a parent and child view, something that doesn't cause a problem in the regular Android OS. I removed all instances of this and it is working fine now. Hopefully this will help someone else out. Thanks!
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Good to know that your problem has been solved. Thanks for sharing the solution.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

yesjee avatar image
yesjee answered
In kindle's which model you found this issue?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.