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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:12:12+00:00 2026-05-23T15:12:12+00:00

When do I create and close an instance of AssetManager. I had a bug

  • 0

When do I create and close an instance of AssetManager.

I had a bug in my program. The DDMS was saying….

07-04 18:44:59.241: DEBUG/KeyguardViewMediator(65): pokeWakelock(5000)
07-04 18:44:59.541: DEBUG/KeyguardViewMediator(65): pokeWakelock(5000)
07-04 18:45:00.101: INFO/ARMAssembler(65): generated scanline__00000077:03545404_00000004_00000000 [ 47 ipp] (67 ins) at [0x33b540:0x33b64c] in 9815520 ns
07-04 18:45:00.281: INFO/ARMAssembler(65): generated scanline__00000177:03515104_00001001_00000000 [ 91 ipp] (114 ins) at [0x33c088:0x33c250] in 2206721 ns
07-04 18:45:00.561: WARN/ActivityManager(65): finishReceiver called but no pending broadcasts
07-04 18:45:10.843: DEBUG/AndroidRuntime(277): Shutting down VM
07-04 18:45:10.843: WARN/dalvikvm(277): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
07-04 18:45:11.191: ERROR/AndroidRuntime(277): FATAL EXCEPTION: main
07-04 18:45:11.191: ERROR/AndroidRuntime(277): android.content.res.Resources$NotFoundException: File res/layout/simple_spinner_item.xml from xml type layout resource ID #0x1090008
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.content.res.Resources.loadXmlResourceParser(Resources.java:1916)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.content.res.Resources.loadXmlResourceParser(Resources.java:1871)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.content.res.Resources.getLayout(Resources.java:731)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.view.LayoutInflater.inflate(LayoutInflater.java:318)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:332)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.widget.AbsSpinner.onMeasure(AbsSpinner.java:192)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.view.View.measure(View.java:8171)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.widget.TableRow.getColumnsWidths(TableRow.java:308)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.widget.TableLayout.findLargestCells(TableLayout.java:497)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.widget.TableLayout.measureVertical(TableLayout.java:462)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.widget.TableLayout.onMeasure(TableLayout.java:428)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.view.View.measure(View.java:8171)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1012)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:381)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.view.View.measure(View.java:8171)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.view.View.measure(View.java:8171)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:526)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.view.View.measure(View.java:8171)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.view.View.measure(View.java:8171)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.view.ViewRoot.performTraversals(ViewRoot.java:801)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.os.Looper.loop(Looper.java:123)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.app.ActivityThread.main(ActivityThread.java:4627)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at java.lang.reflect.Method.invokeNative(Native Method)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at java.lang.reflect.Method.invoke(Method.java:521)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at dalvik.system.NativeStart.main(Native Method)
07-04 18:45:11.191: ERROR/AndroidRuntime(277): Caused by: java.lang.RuntimeException: Assetmanager has been closed
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:483)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     at android.content.res.Resources.loadXmlResourceParser(Resources.java:1898)
07-04 18:45:11.191: ERROR/AndroidRuntime(277):     ... 36 more

I won’t post all my codes since it is really long but my program is structured similar to this….

public class myAppActivity extends Activity {

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

        usesAnInstanceOfAssetManager();
        addsTextToASpinner(); 
    }


    private void usesAnInstanceOfAssetManager() {
        AssetManager assetManager = getAssets();
        ///blah blah blah.....
        assetManager.close();
        return;
    }

    public void addsTextToASpinner(){
        // code to add text fields to a spinner
        // executing this function caused the error shown above
        return;
    }
}

I noticed the line:

07-04 18:45:11.191: ERROR/AndroidRuntime(277): Caused by: java.lang.RuntimeException: Assetmanager has been closed

So the problem seemed to be that the first function “usesAnInstanceOfAssetManager” was closing the asset manager and the second function needed the assetManager. I commented out the assetManager.close() line in the function “usesAnInstanceOfAssetManager” and my app did not crash. So my question/s is….

What is the best practice for using an AssetManager? Can I only use it once per program? I though by declaring an instance of it and closing it when I was done was the appropriate course of action but that doesn’t appear to be the case. Is AssetManager “static”? Do I always need it?

  • 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-23T15:12:13+00:00Added an answer on May 23, 2026 at 3:12 pm

    You can close the AssetManager after the Activity called AddTextToSpinner() I assume.
    If you need it else where, just open it again.

    If you need more info about the AssetManager you should visit this link:
    http://developer.android.com/reference/android/content/res/AssetManager.html

    The way I use my AssetManager is as following:

    I call my parseXMLFile(),
    in there I open my AssetManager,
    I open my XML file, Read and Store the data in objects,
    close AssetManager.

    This way I use the AssetManager once, and later in my application I can just work with the objects.

    I hope this was the answer you were looking for!

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

Sidebar

Related Questions

I am looking for a hash-algorithm, to create as close to a unique hash
How do I create a function that will close the window after 2 seconds?
using (var file_stream = File.Create(users.xml)) { var serializer = new XmlSerializer(typeof(PasswordManager)); serializer.Serialize(file_stream, this); file_stream.Close();
I want to be able to create modal dialogs, with, for example close: function()
I'm trying to create a generalized event for my Close buttons, where they have
Please advice why I'm getting an exception on trying to create a JSONArray instance?
How I can create for my application one's own instance excel and use it
Hi i'm trying to create a sever/client program that takes up to 5 clients
if i create a new instance of JdbcTemplate like so; JdbcTemplate jdbcTemplate = new
Often times, I start a new instance of Visual Studio, just to create a

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.