Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9020821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:06:46+00:00 2026-06-16T05:06:46+00:00

I am trying to set up an alert dialog, using the below code, but

  • 0

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.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:06:47+00:00Added an answer on June 16, 2026 at 5:06 am

    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

        //---scales the alertdialog items to the right size---
        Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(), R.drawable.tick); 
        int width = bitmapOrg.getWidth(); 
        int height = bitmapOrg.getHeight(); 
        int newWidth = 200; 
        int newHeight = 200;
    
        // calculate the scale - in this case = 0.4f 
        float scaleWidth = ((float) newWidth) / width;
        float scaleHeight = ((float) newHeight) / height; 
    
        // create matrix for the manipulation
        Matrix matrix = new Matrix();  
    
        // resize the bit map
        matrix.postScale(scaleWidth, scaleHeight);
    
        // rotate the Bitmap
        matrix.postRotate(0);  
    
        // recreate the new Bitmap 
        Bitmap resizedBitmap = Bitmap.createBitmap(bitmapOrg, 0, 0, width, height, matrix, true);   
    
        // make a Drawable from Bitmap to allow to set the BitMap  // to the ImageView, ImageButton or what ever 
        BitmapDrawable bmd = new BitmapDrawable(resizedBitmap);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to set the android Theme.Light theme for my alert dialog, but
I am trying to set up an alert that will send me an email
Trying to set up Cancan within an app of mine and having trouble with
I am trying to use an alert dialog to prompt for a username and
I'm trying to modify and set alert templates on a SP (working on a
Hi I am trying to set href using Jquery inside click event of RadioButtonList
I'm trying to set up jsTree to dynamically accept JSON data from django. This
I am trying to set a background color for an ID + Variable but
I'm trying to set up a form for a sharepoint list using infopath. However,
I'm quite a noob at Jquery but I'm trying to set a variable based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.