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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:10:01+00:00 2026-06-02T06:10:01+00:00

My app has a few activities, all have an options menu, which is the

  • 0

My app has a few activities, all have an options menu, which is the same. It works fine, only on one activity (a ListView subclass), it crashes when clicking the menu button.

This only happens in 4.x (maybe 3.x – can’t check), but not 2.3 or prior. Tested in the emulator and on different devices.

Interesting fact: When I rotate the device after the activity has rendered and press the menu button then, it works fine.

Also, the menu works while the list adapter still loads and the list is empty. Once the list is filled the problem occurs (only above version 2.3 as mentioned)

The menu itself can be a simple one-liner without a resource at all, it still happens.

Options menu code:

/**
 * Prepare the options menu
 * @param menu The menu
 * @return You must return true for the menu to be displayed; if you return false it will not be shown.
 */
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    menu.clear();

    title = getString(R.string.optionsmenu_search);
    MenuItem item1 = menu.add(Menu.NONE, MENU_SEARCH, Menu.NONE, title);        
    item1.setIcon(R.drawable.ic_menu_search);

    return super.onPrepareOptionsMenu(menu);
}

 * Handle options menu click
 * @param item menu item
 * @return
 */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        // ...
    }
    return OptionsMenu.itemSelected(this, item) || super.onOptionsItemSelected(item);
}

The exception does not happen in the app code, nor does it seem to reference to a ressource of the app (they exist, R was deleted/rebuilt many times, project cleared etc)

Stack trace:
(it seems to reference some xml resource, but the menu’s not xml-based)

04-13 23:45:39.081: E/AndroidRuntime(2933): FATAL EXCEPTION: main
04-13 23:45:39.081: E/AndroidRuntime(2933): android.content.res.Resources$NotFoundException: Resource ID #0x1090044
04-13 23:45:39.081: E/AndroidRuntime(2933):     at android.content.res.Resources.getValue(Resources.java:1019)
04-13 23:45:39.081: E/AndroidRuntime(2933):     at android.content.res.Resources.loadXmlResourceParser(Resources.java:2107)
04-13 23:45:39.081: E/AndroidRuntime(2933):     at android.content.res.Resources.getLayout(Resources.java:858)
04-13 23:45:39.081: E/AndroidRuntime(2933):     at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
04-13 23:45:39.081: E/AndroidRuntime(2933):     at com.android.internal.view.menu.BaseMenuPresenter.getMenuView(BaseMenuPresenter.java:70)
04-13 23:45:39.081: E/AndroidRuntime(2933):     at com.android.internal.policy.impl.PhoneWindow$PanelFeatureState.getIconMenuView(PhoneWindow.java:3298)
04-13 23:45:39.081: E/AndroidRuntime(2933):     at com.android.internal.policy.impl.PhoneWindow.initializePanelContent(PhoneWindow.java:1096)
04-13 23:45:39.081: E/AndroidRuntime(2933):     at com.android.internal.policy.impl.PhoneWindow.openPanel(PhoneWindow.java:559)
04-13 23:45:39.081: E/AndroidRuntime(2933):     at com.android.internal.policy.impl.PhoneWindow.onKeyUpPanel(PhoneWindow.java:817)
04-13 23:45:39.081: E/AndroidRuntime(2933):     at com.android.internal.policy.impl.PhoneWindow.onKeyUp(PhoneWindow.java:1486)
04-13 23:45:39.081: E/AndroidRuntime(2933):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1813)
04-13 23:45:39.081: E/AndroidRuntime(2933):     at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3300)
04-13 23:45:39.081: E/AndroidRuntime(2933):     at android.view.ViewRootImpl.handleFinishedEvent(ViewRootImpl.java:3273)
04-13 23:45:39.081: E/AndroidRuntime(2933):     at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2436)
04-13 23:45:39.081: E/AndroidRuntime(2933):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-13 23:45:39.081: E/AndroidRuntime(2933):     at android.os.Looper.loop(Looper.java:137)
04-13 23:45:39.081: E/AndroidRuntime(2933):     at android.app.ActivityThread.main(ActivityThread.java:4340)
04-13 23:45:39.081: E/AndroidRuntime(2933):     at java.lang.reflect.Method.invokeNative(Native Method)
04-13 23:45:39.081: E/AndroidRuntime(2933):     at java.lang.reflect.Method.invoke(Method.java:511)
04-13 23:45:39.081: E/AndroidRuntime(2933):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-13 23:45:39.081: E/AndroidRuntime(2933):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-13 23:45:39.081: E/AndroidRuntime(2933):     at dalvik.system.NativeStart.main(Native Method)

Any idea? Help greatly appreciated, it’s the one pre-launch blocker..

  • 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-02T06:10:03+00:00Added an answer on June 2, 2026 at 6:10 am

    Finally solved the problem. It’s quite hidden in this line of code (which appears in a totally different location):

    mResources = new Resources(mgr, mMetrics, null);
    

    The last parameter should contain the configuration, but contained null. Seems that worked till Android 3.x

    Here’s the old code containing the trouble line:

    private static void prepareResources(Context context) {
        if (mMetrics != null)
            return;
        mMetrics = new DisplayMetrics();
        Activity act = (Activity)context;
        act.getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
        AssetManager mgr = context.getAssets();
        mResources = new Resources(mgr, mMetrics, null);
    }
    

    This solved the issue (note the last line):

    private static void prepareResources(Context context) {
        if (mMetrics != null)
            return;
        mMetrics = new DisplayMetrics();
        Activity act = (Activity)context;
        act.getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
        AssetManager mgr = context.getAssets();
        mResources = new Resources(mgr, mMetrics, act.getResources().getConfiguration());
    }
    

    (The code is in the UrlImageViewHelper (https://github.com/koush/UrlImageViewHelper) class we use in the project)

    See also Crash when opening Option Menu

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

Sidebar

Related Questions

I have a .net winforms app which has a few animation effects, fade ins
I created a MainActivity in which the user has a few app options, displayed
I have an app which has 4 activities in it.Within app, history activities, i.e.
i have an app that has a few checkboxes in the settings and then
I'm developing an app that has a few services, which communicate using AIDL. In
I have an app written in PHP, MySQL, etc. The app has a few
I got an app which has a few slow pages, so I am trying
I have few SQL scripts which setups the db of an app. have few
I have a web app that has a few processes that can take up
In my NodeJS express application I have app.js that has a few common routes.

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.