Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to solve OutOfMemoryError using LayerDrawable
    primarykey
    data
    text
    <p><strong>Error:</strong></p> <pre><code>java.lang.OutOfMemoryError at android.graphics.Bitmap.nativeCreate(Native Method) at android.graphics.Bitmap.createBitmap(Bitmap.java:605) at android.graphics.Bitmap.createBitmap(Bitmap.java:551) at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437) at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:618) at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:593) at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:445) at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:775) at android.content.res.Resources.loadDrawable(Resources.java:1968) at android.content.res.Resources.getDrawable(Resources.java:677) at android.widget.ImageView.resolveUri(ImageView.java:542) at android.widget.ImageView.setImageResource(ImageView.java:315) at app.Main.GridActivity.initaliseLevel(GridActivity.java:245) at app.Main.GridActivity.load_player_settings(GridActivity.java:180) at app.Main.GridActivity.onResume(GridActivity.java:79) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1158) at android.app.Activity.performResume(Activity.java:4607) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2448) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2486) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2000) at android.app.ActivityThread.access$600(ActivityThread.java:128) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4517) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760) at dalvik.system.NativeStart.main(Native Method) </code></pre> <p>The images are set by:</p> <pre><code>ImageButton b0 = (ImageButton) findViewById(R.id.ImageButton00); Resources r = getResources(); Drawable[] layers = new Drawable[2]; layers[0] = r.getDrawable(R.drawable.image); layers[1] = r.getDrawable(R.drawable.imagetwo); LayerDrawable layerDrawable = new LayerDrawable(layers); b0.setImageDrawable(layerDrawable); </code></pre> <p>From reading other answers, I gathered that the images need to be recycled after use. Is this the best option? If so how can a LayerDrawable be converted to a bitmap, so it can be recycled?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload