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

  • Home
  • SEARCH
  • 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 4618574
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:17:12+00:00 2026-05-22T02:17:12+00:00

I have an activity containing two imagebuttons. If the user clicks back an alertDialog

  • 0

I have an activity containing two imagebuttons. If the user clicks back an alertDialog is shown. While the alert is shown, if the orientation is changed back and forth a few times the application crashes with this message:

ERROR/dalvikvm-heap(10988): 3363556-byte external allocation too large for this process.
ERROR/dalvikvm(10988): Out of memory: Heap Size=4935KB, Allocated=2594KB, Bitmap Size=19579KB ERROR/GraphicsJNI(10988): VM won't let us allocate 3363556 bytes

If the AlertDialog is not there, the application doesn’t crash.

public class StartPageView extends Activity implements OnClickListener, android.content.DialogInterface.OnClickListener
{
    private static final String TAG = "StartPageView";
    private ImageButton vacButton;
    private ImageButton sickButton;
    private AlertDialog alert;
    private static boolean alertDismissedByLifeCycle = false;


@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.startpage);

    vacButton = (ImageButton)findViewById(R.id.gotovac_btn);
    vacButton.setOnClickListener(this);

    sickButton = (ImageButton)findViewById(R.id.gotosick_btn);
    sickButton.setOnClickListener(this); 

    if(alertDismissedByLifeCycle)
    {
        alertDismissedByLifeCycle = false;
        showAlert();
    }
}

@Override
protected void onStop() 
{
    if(alert != null && alert.isShowing())
    {
        alertDismissedByLifeCycle = true;
        alert.dismiss();
    }
    super.onStop();
}

//GO TO VACATION VIEW OR SICK VIEW

//user clicked on vacView button or sickView button
@Override
public void onClick(View v) 
{
    if(v.equals(this.vacButton))
    {
         Intent i = new Intent(this, VacationLeaveView.class);
         startActivity(i);
    }
    if(v.equals(this.sickButton))
    {
         Intent i = new Intent(this, SickLeaveView.class);
         startActivity(i);

    }

}


//LOG OUT

//user pressed the back button
@Override
public void onBackPressed() 
{
    showAlert();
}
//OnClickListener for logging out warning
@Override
public void onClick(DialogInterface dialog, int which) 
{
    if(which == DialogInterface.BUTTON_POSITIVE)
    {
        MainController.getInstance().clearAllChildren();
        dialog.cancel();
        this.finish();
    }
    else
        dialog.cancel();
}

//DIALOG

private void showAlert()
{
    if(alert == null)
    {
        AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);

        alertDialog.setMessage("Vill du logga ut från förskoleportalen?");
        alertDialog.setPositiveButton("Ja", this);
        alertDialog.setNegativeButton("Nej", this);

        alert = alertDialog.create();

        // Title for AlertDialog
        alert.setTitle("Logga ut");
    }

    alert.show();
}
  • 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-05-22T02:17:13+00:00Added an answer on May 22, 2026 at 2:17 am

    Your context of “this” is almost certainly the cause. You need to explicitly specify context to avoid this issue. Your very issue is discussed here: Avoiding Memory Leaks

    The problem is this … when you add your images inside the activity to something with the context of “this” and then change the orientation the image gets passed along with everything else that is “this” to the onCreate() method as part of the bundle. Do that over and over again and you actually end up with 1 image per orientation change in memory. The Android documentation speaks to this verbatim.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a database containing 3 tables in a grails application: User Activity
I have an activity that has a TabHost containing a set of TabSpecs each
I have a couple of tables which are used to log user activity for
I have an activity MyActivity that extends from MapActivity. In the .xml file containing
Currently I have a TabHost implemented with 3 tabs each containing a separate activity.
I have a UIPicker with 3 components containing numeric values, this allows the user
I have an activity group containing 3 activities. When a button is pressed, I
i have created a workflow activity that do give the item creater of a
I have a need to do auditing all database activity regardless of whether it
I have a web-based application that notifies users of activity on the site via

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.