I'm developing an Android Application for a tablet (1024x768). I searched and find some solutions here, but anyone solved me the problem. The application has 5 screens and each screen has an ImageView that I load:
<ImageView
android:id="@+id/imageView1"
android:layout_width="1024dp"
android:layout_height="768dp"
android:layout_centerHorizontal="TRUE"
android:src="@drawable/scene1"
/>
The first and the second screen loads good, but when I try to load the third one, I get the following errors (Every screen I load by startActivity which its layout. It's not a layout error, because if I load them with a different order, I can load two and the third one crases too):
05-28 17:03:51.774: E/AndroidRuntime(401): java.lang.RuntimeException: Unable to start activity ComponentInfo{xxx}: android.view.InflateException: Binary XML file line #10: Error inflating class <unknown>
05-28 17:03:51.774: E/AndroidRuntime(401): Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class <unknown>
05-28 17:03:51.774: E/AndroidRuntime(401): Caused by: java.lang.reflect.InvocationTargetException
05-28 17:03:51.774: E/AndroidRuntime(401): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
I tried several things:
@Override
public void onPause()
{
super.onPause();
Log.i("URI", "Syste.gc");
// yada yada yada...
System.gc();
}
and
@Override
protected void onDestroy()
{
super.onDestroy();
unbindDrawables(findViewById(R.id.RootView));
System.gc();
}
private void unbindDrawables(View view)
{
if (view.getBackground() != null)
{
view.getBackground().setCallback(null);
}
if (view instanceof ViewGroup)
{
for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++)
{
unbindDrawables(((ViewGroup) view).getChildAt(i));
}
((ViewGroup) view).removeAllViews();
}
}
but I always get the error.
The images are PNG and its weight is lower than 50k.
Any suggestions?
Thanks!