My MainScreen contain 4 ImageViews, every ImageView will send the user to category activity, then Send Extra data to show content in a ListView, but once I click on any ImageView the app stops working, and shows me this error message in the Logcat. Anyone know what this mean ?
Blockquote 04-13 21:43:53.337 15929-15929/com.ibuilder.the50recipes E/AndroidRuntime: FATAL EXCEPTION: main Process: com.ibuilder.the50recipes, PID: 15929 java.lang.OutOfMemoryError: Failed to allocate a 25600012 byte allocation with 9652808 free bytes and 9MB until OOM at dalvik.system.VMRuntime.newNonMovableArray(Native Method) at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:620) at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:455) at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1152) at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:855) at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:706) at android.content.res.Resources.getDrawable(Resources.java:776) at android.content.Context.getDrawable(Context.java:530) at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:351) at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:200) at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:188) at android.support.v7.content.res.AppCompatResources.getDrawable(AppCompatResources.java:100) at android.support.v7.widget.AppCompatImageHelper.setImageResource(AppCompatImageHelper.java:85) at android.support.v7.widget.AppCompatImageView.setImageResource(AppCompatImageView.java:94) at com.ibuilder.the50recipes.Category_New$CustomAdapter.getView(Category_New.java:659) at android.widget.AbsListView.obtainView(AbsListView.java:2406) at android.widget.ListView.makeAndAddView(ListView.java:1975) at android.widget.ListView.fillDown(ListView.java:709) at android.widget.ListView.fillFromTop(ListView.java:770) at android.widget.ListView.layoutChildren(ListView.java:1749) at android.widget.AbsListView.onLayout(AbsListView.java:2205) at android.view.View.layout(View.java:17564) at android.view.ViewGroup.layout(ViewGroup.java:5654) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741) at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1730) at android.widget.LinearLayout.onLayout(LinearLayout.java:1496) at android.view.View.layout(View.java:17564) at android.view.ViewGroup.layout(ViewGroup.java:5654) at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079) at android.view.View.layout(View.java:17564) at android.view.ViewGroup.layout(ViewGroup.java:5654) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:17564) at android.view.ViewGroup.layout(ViewGroup.java:5654) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585) at android.widget.LinearLayout.onLayout(LinearLayout.java:1494) at android.view.View.layout(View.java:17564) at android.view.ViewGroup.layout(ViewGroup.java:5654) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at android.view.View.layout(View.java:17564) at android.view.ViewGroup.layout(ViewGroup.java:5654) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585) at android.widget.LinearLayout.onLayout(LinearLayout.java:1494) at android.view.View.layout(View.java:17564) at android.view.ViewGroup.layout(ViewGroup.java:5654) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323) at android.widget.FrameLayout.onLayout(FrameLayout.java:261) at com.android.internal.policy.DecorView.onLayout(DecorView.java:725) at android.view.View.layout(View.java:17564) at android.view.ViewGroup.layout(ViewGroup.java:5654) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2406) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2126) 04-13 21:43:53.337 15929-15929/com.ibuilder.the50recipes E/AndroidRuntime: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1286) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6536) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871) at android.view.Choreographer.doCallbacks(Choreographer.java:683) at android.view.Choreographer.doFrame(Choreographer.java:619) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6247) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
It looks like it's trying to allocate 25 mb of memory when it only has 9 mb until out of memory.
You'll probably need to read up on how to load large bitmaps more efficiently:
https://developer.android.com/topic/performance/graphics/load-bitmap.html
From there it says how you can load a resource efficiently:
public static Bitmap decodeSampledBitmapFromResource(Resources res, int resId,
int reqWidth, int reqHeight) {
// First decode with inJustDecodeBounds=true to check dimensions
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(res, resId, options);
// Calculate inSampleSize
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
// Decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
return BitmapFactory.decodeResource(res, resId, options);
}