I have a network task defined inside of an AsyncTask that takes approximately 2-3 seconds to complete.
When I add the animation code below:
<?xml version="1.0" encoding="utf-8"?>
<rotate
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:duration="60"
android:interpolator="@android:anim/linear_interpolator" />
and then in my activity execute it as follows:
progressImageView = (ImageView) getWindow().findViewById(
R.id.progressImageView);
progressAnimation = AnimationUtils.loadAnimation(this, R.anim.progress);
progressImageView.startAnimation(progressAnimation);
The network call takes approximately 12-13 seconds to complete. Am I doing something incredibly wrong here?
I’d guess the problem is the duration value, it is specified in milliseconds, I’m guessing you intended it to be more like 6000 or 60000 (1 min).
A value that small is probably causing the UI thread to get backed up with a large number of frame updates that delay it from processing the the onProgressUpdate and onPostExecute code in the Async task.
Try setting the duration to a larger value.