I am trying to set up an alert dialog, using the below code, but the app keeps crashing on this point. Any obvious mistakes?
AlertDialog alertDialog = new AlertDialog.Builder(
Crossword1.this).create();
alertDialog.setTitle("Well done, the crossword is complete!");
alertDialog.setMessage("well done cuz");
alertDialog.setIcon(R.drawable.tick);
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
alertDialog.show();
Logcat below, mentions memory although I don’t see why the alertdialog box should be causing a memory error (the app runs fine if the alertdialog is commented out)
12-21 17:57:33.180: D/BounceScrollRunnableDefault(24966): start(1554.2593), mBounceExtent:0.0
12-21 17:57:33.180: D/BounceScrollRunnableDefault(24966): mBounceExtentCoef = -205.16223
12-21 17:57:34.335: D/BounceScrollRunnableDefault(24966): start(0.0), mBounceExtent:-11.0
12-21 17:57:34.335: D/BounceScrollRunnableDefault(24966): mBounceExtentCoef = -11.0
12-21 17:57:34.555: D/BounceScrollRunnableDefault(24966): start(0.0), mBounceExtent:-19.245642
12-21 17:57:34.555: D/BounceScrollRunnableDefault(24966): mBounceExtentCoef = -19.245642
12-21 17:57:35.505: I/dalvikvm-heap(24966): Clamp target GC heap from 65.159MB to 64.000MB
12-21 17:57:35.505: D/dalvikvm(24966): GC_FOR_ALLOC freed 580K, 2% free 64467K/65479K, paused 20ms
12-21 17:57:35.505: I/dalvikvm-heap(24966): Forcing collection of SoftReferences for 2903056-byte allocation
12-21 17:57:35.545: I/dalvikvm-heap(24966): Clamp target GC heap from 65.151MB to 64.000MB
12-21 17:57:35.545: D/dalvikvm(24966): GC_BEFORE_OOM freed 9K, 2% free 64458K/65479K, paused 27ms
12-21 17:57:35.545: E/dalvikvm-heap(24966): Out of memory on a 2903056-byte allocation.
Thanks @Andro Selva for the answer
The memory problem is being caused by the icon. If I comment out the icon line of code then the dialog runs fine.
If I resize the icon like so, then the whole thing runs fine