I am using an animation in my splash screen. While the splash is shown the application does some preparations in the background like login.
The animation is created by using animation list as such:
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/part_00001" android:duration="35" />
<item android:drawable="@drawable/part_00002" android:duration="35" />
<item android:drawable="@drawable/part_00003" android:duration="35" />
<item android:drawable="@drawable/part_00004" android:duration="35" />
<item android:drawable="@drawable/part_00005" android:duration="35" />
<item android:drawable="@drawable/part_00006" android:duration="35" />
<item android:drawable="@drawable/part_00007" android:duration="35" />
<item android:drawable="@drawable/part_00008" android:duration="35" />
<item android:drawable="@drawable/part_00009" android:duration="35" />
<item android:drawable="@drawable/part_00010" android:duration="35" />
.
.
.
<item android:drawable="@drawable/part_00069" android:duration="35" />
<item android:drawable="@drawable/part_00070" android:duration="35" />
</animation-list>
This is my splash activity layout:
<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#000">
<ImageView
android:id="@+id/logo_animation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
</RelativeLayout>
Then, to start the animation I do the following in onCreate method:
ImageView rocketImage;
AnimationDrawable rocketAnimation;
rocketImage = (ImageView) findViewById(R.id.logo_animation);
rocketImage.setBackgroundResource(R.drawable.movie);
rocketAnimation = (AnimationDrawable) rocketImage.getBackground();
rocketAnimation.start();
However, after I run the application 3-4 times it crashes and says:
java.lang.OutOfMemoryError: Failed to allocate a 4665612 byte allocation with 700512 free bytes and 684KB until OOM
What can I overcome this issue?