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 8077499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:29:29+00:00 2026-06-05T15:29:29+00:00

I’m developing an android game, and just added a main menu. This is a

  • 0

I’m developing an android game, and just added a main menu. This is a separate activity – so when someone clicks the ‘new game’ button on the menu, it opens a new intent to the game activity.

My problem is if the user hits ‘back’, it closes the game and returns to the main menu. When I hit ‘New Game’ again, it crashes.

I think it is attempting to make a second version of the game, and running out of memory. Should I be trying to hold a copy of the game activity in the menu, then reopen it if they hit ‘New Game’ again? Or is there an easier way to do this?

My “new game” button listener does the following: (IslandGame is my main game class – the bundle is just to tell it whether to start a new game or load a previous game, and which level to start in)

ButtonNewGame.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {                 
            Bundle bundle = new Bundle();
            bundle.putString("RESTORE", "NEW"); //in the restore key, say we want a new game
            bundle.putInt("CAMPAIGN", 1); //start in campaign #1

            Intent intent = new Intent(Intent.ACTION_RUN);
            intent.putExtras(bundle);
            intent.setClassName(thisActivity, IslandGame.class.getName());
            startActivity(intent);
        }         
    });

The logcat is:

06-09 17:42:34.199: E/dalvikvm-heap(239): 147456-byte external allocation too large for this process.
06-09 17:42:34.199: E/(239): VM won't let us allocate 147456 bytes
06-09 17:42:34.209: D/AndroidRuntime(239): Shutting down VM
06-09 17:42:34.209: W/dalvikvm(239): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
06-09 17:42:34.219: E/AndroidRuntime(239): Uncaught handler: thread main exiting due to uncaught exception
06-09 17:42:34.249: E/AndroidRuntime(239): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dylan.island/com.dylan.island.IslandGame}: android.view.InflateException: Binary XML file line #37: Error inflating class <unknown>
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.app.ActivityThread.access$2200(ActivityThread.java:119)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.os.Handler.dispatchMessage(Handler.java:99)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.os.Looper.loop(Looper.java:123)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.app.ActivityThread.main(ActivityThread.java:4363)
06-09 17:42:34.249: E/AndroidRuntime(239):  at java.lang.reflect.Method.invokeNative(Native Method)
06-09 17:42:34.249: E/AndroidRuntime(239):  at java.lang.reflect.Method.invoke(Method.java:521)
06-09 17:42:34.249: E/AndroidRuntime(239):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
06-09 17:42:34.249: E/AndroidRuntime(239):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
06-09 17:42:34.249: E/AndroidRuntime(239):  at dalvik.system.NativeStart.main(Native Method)
06-09 17:42:34.249: E/AndroidRuntime(239): Caused by: android.view.InflateException: Binary XML file line #37: Error inflating class <unknown>
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.view.LayoutInflater.createView(LayoutInflater.java:513)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
06-09 17:42:34.249: E/AndroidRuntime(239):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.app.Activity.setContentView(Activity.java:1622)
06-09 17:42:34.249: E/AndroidRuntime(239):  at com.dylan.island.IslandGame.onCreate(IslandGame.java:76)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
06-09 17:42:34.249: E/AndroidRuntime(239):  ... 11 more
06-09 17:42:34.249: E/AndroidRuntime(239): Caused by: java.lang.reflect.InvocationTargetException
06-09 17:42:34.249: E/AndroidRuntime(239):  at com.dylan.island.IslandView.<init>(IslandView.java:1983)
06-09 17:42:34.249: E/AndroidRuntime(239):  at java.lang.reflect.Constructor.constructNative(Native Method)
06-09 17:42:34.249: E/AndroidRuntime(239):  at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.view.LayoutInflater.createView(LayoutInflater.java:500)
06-09 17:42:34.249: E/AndroidRuntime(239):  ... 23 more
06-09 17:42:34.249: E/AndroidRuntime(239): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.graphics.Bitmap.nativeCreate(Native Method)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:346)
06-09 17:42:34.249: E/AndroidRuntime(239):  at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:372)
06-09 17:42:34.249: E/AndroidRuntime(239):  at com.dylan.island.IslandView$IslandThread.initimages(IslandView.java:435)
06-09 17:42:34.249: E/AndroidRuntime(239):  at com.dylan.island.IslandView$IslandThread.beginLevel(IslandView.java:220)
06-09 17:42:34.249: E/AndroidRuntime(239):  at com.dylan.island.IslandView$IslandThread.<init>(IslandView.java:215)
06-09 17:42:34.249: E/AndroidRuntime(239):  ... 27 more
  • 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-05T15:29:30+00:00Added an answer on June 5, 2026 at 3:29 pm

    I think it is attempting to make a second version of the game, and running out of memory.

    You are absolutely correct. If you properly finished the game activity, then it should be trying to create a second version because the first version should be gone.

    Should I be trying to hold a copy of the game activity in the menu, then reopen it if they hit ‘New Game’ again?

    In general, this is considered a horribly bad practice for a number of reasons. The most important of these is a memory leak due to contexts.

    Or is there an easier way to do this?

    You may define the game activity as a singleTask or singleInstance. An issue with this (at the moment) is that it is not a solution to fix memory bugs. SingleTasks are programmed differently than multiple instance applications and there are other considerations. Since your issue lies in the fact that you have memory being used in the first place, before going this route, I would definitely review the following:

    1. Make sure all resources are released. Of particular concern here is any static reference to a View. If you have them, clean them up.

    2. Make sure ALL bitmaps are recycled. Sometimes when resizing bitmaps, the original is left behind. Often a silly oversight. Just take a look. 🙂

    3. If you are accessing files, make sure they are closed. Almost never the problem, but always worth a try.

    4. Add a System.gc() call after your game activity is finished. This really can help after a major release of resources. Unfortunately, it is not guaranteed to. In your case, it might be best in the onResume() of your Main Menu.

    Once you have exhausted all of those, then the singleTask route is simply choice of implementation.

    Hope this helps,

    FuzzicalLogic

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I want use html5's new tag to play a wav file (currently only supported
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string

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.