1


My animation works on SGS2 for example, but not on SGS 1 or the emulator (For some reason other animation that I built just the same works perfectly fine on every device)

In addition, even on devices that run the animation, when OnPostExcute is called the animation stops, while in other similar animations, which are also nested in ASyncTask, the animation doesn't stop until the stop() is called

The dimensions of each frame are 512x512

Here's the animation-list file:

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">

    <item android:drawable="@drawable/logo0" android:duration="35" />
    <item android:drawable="@drawable/logo1" android:duration="35" />
    <item android:drawable="@drawable/logo2" android:duration="35" />
    <item android:drawable="@drawable/logo3" android:duration="35" />
    <item android:drawable="@drawable/logo4" android:duration="35" />
    <item android:drawable="@drawable/logo5" android:duration="35" />
    <item android:drawable="@drawable/logo6" android:duration="35" />
    <item android:drawable="@drawable/logo7" android:duration="35" />
    <item android:drawable="@drawable/logo8" android:duration="35" />
    <item android:drawable="@drawable/logo9" android:duration="35" />
    <item android:drawable="@drawable/logo10" android:duration="35" />
    <item android:drawable="@drawable/logo11" android:duration="35" />
    <item android:drawable="@drawable/logo12" android:duration="35" />
    <item android:drawable="@drawable/logo13" android:duration="35" />
    <item android:drawable="@drawable/logo14" android:duration="35" />
    <item android:drawable="@drawable/logo15" android:duration="35" />
    <item android:drawable="@drawable/logo16" android:duration="35" />
    <item android:drawable="@drawable/logo17" android:duration="35" />
    <item android:drawable="@drawable/logo18" android:duration="35" />
    <item android:drawable="@drawable/logo19" android:duration="35" />
    <item android:drawable="@drawable/logo20" android:duration="35" />
    <item android:drawable="@drawable/logo21" android:duration="35" />
    <item android:drawable="@drawable/logo22" android:duration="35" />
    <item android:drawable="@drawable/logo23" android:duration="35" />
    <item android:drawable="@drawable/logo24" android:duration="35" />
    <item android:drawable="@drawable/logo25" android:duration="35" />
    <item android:drawable="@drawable/logo26" android:duration="35" />
    <item android:drawable="@drawable/logo27" android:duration="35" />
    <item android:drawable="@drawable/logo28" android:duration="35" />
    <item android:drawable="@drawable/logo29" android:duration="35" />
    <item android:drawable="@drawable/logo30" android:duration="35" />
    <item android:drawable="@drawable/logo31" android:duration="35" />
    <item android:drawable="@drawable/logo32" android:duration="35" />
    <item android:drawable="@drawable/logo33" android:duration="35" />
    <item android:drawable="@drawable/logo34" android:duration="35" />
    <item android:drawable="@drawable/logo35" android:duration="35" />
    <item android:drawable="@drawable/logo36" android:duration="35" />
    <item android:drawable="@drawable/logo37" android:duration="35" />
    <item android:drawable="@drawable/logo38" android:duration="35" />
    <item android:drawable="@drawable/logo39" android:duration="35" />
    <item android:drawable="@drawable/logo40" android:duration="35" />
    <item android:drawable="@drawable/logo41" android:duration="35" />
    <item android:drawable="@drawable/logo42" android:duration="35" />
    <item android:drawable="@drawable/logo43" android:duration="35" />
    <item android:drawable="@drawable/logo44" android:duration="35" />
    <item android:drawable="@drawable/logo45" android:duration="35" />
    <item android:drawable="@drawable/logo46" android:duration="35" />
    <item android:drawable="@drawable/logo47" android:duration="35" />
    <item android:drawable="@drawable/logo48" android:duration="35" />
    <item android:drawable="@drawable/logo49" android:duration="35" />
    <item android:drawable="@drawable/logo50" android:duration="35" />
    <item android:drawable="@drawable/logo51" android:duration="35" />
    <item android:drawable="@drawable/logo52" android:duration="35" />
    <item android:drawable="@drawable/logo53" android:duration="35" />
    <item android:drawable="@drawable/logo54" android:duration="35" />
    <item android:drawable="@drawable/logo55" android:duration="35" />
    <item android:drawable="@drawable/logo56" android:duration="35" />
    <item android:drawable="@drawable/logo57" android:duration="35" />
    <item android:drawable="@drawable/logo58" android:duration="35" />
    <item android:drawable="@drawable/logo59" android:duration="35" />

</animation-list>

Here's the code that should start the animation:

    final ImageView logoAnimation = (ImageView) findViewById(R.id.logoAnimation);
    logoAnimation.setImageResource(R.drawable.none);
    logoAnimation.setBackgroundResource(R.drawable.logo_animation);
    final AnimationDrawable frameAnimation = (AnimationDrawable) logoAnimation
            .getBackground();

    class Init extends AsyncTask<Void, Boolean, Boolean> {
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            frameAnimation.start();
        }

        @Override
        protected Boolean doInBackground(Void... params) {
            if (!isNetworkAvailable()) {
                return false;
            } else {
                try {
                    CheckAll();
                } catch (IOException e) {
                }
            }
            return true;
        }

        @Override
        protected void onPostExecute(Boolean result) {
            super.onPostExecute(result);
            frameAnimation.stop();
            if (result) {
                Intent openMain = new Intent(c, Main.class);
                startActivity(openMain);
                Splash.this.finish();
            } else {

                Builder alertDialog = new AlertDialog.Builder(Splash.this);
                alertDialog
                        .setMessage(getString(R.string.noInternetConnection));
                alertDialog.setNegativeButton(getString(R.string.close),
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog,
                                    int which) {
                                Splash.this.finish();
                            }
                        });
                alertDialog.show();
            }
        }

    }
    new Init().execute();

And I don't know if it is needed, but here's the layout xml file:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/splash"
        android:orientation="vertical" >

        <ImageView
        android:id="@+id/logoAnimation"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:src="@drawable/logo0"
        android:contentDescription="@null" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/logoAnimation"
        android:layout_centerHorizontal="true"
        android:text="@string/loading"
        android:textAppearance="?android:attr/textAppearanceLarge" />

</RelativeLayout>
RE6
  • 2,684
  • 4
  • 31
  • 57
  • What do you mean by "it works"? Or actually, what does not work on the other devices? – Thomas Jungblut Aug 10 '12 at 15:28
  • By works I mean moving. On other devices you only see the first frame... – RE6 Aug 10 '12 at 15:29
  • [An animation may not work when called in start()](http://stackoverflow.com/a/2790930/94363) ; I guess onPreExectute has the same issue – rds Dec 29 '12 at 22:35

1 Answers1

1

Maybe you can use the built in ProgressBar and change it's drawable to whatever you want.