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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:53:00+00:00 2026-05-30T18:53:00+00:00

I’m facing a weird problem with my app: When pushing the menu button, my

  • 0

I’m facing a weird problem with my app:

When pushing the menu button, my app crashes. BUT! only when i launch the app in webview!

this works :

super.loadUrl("http://www.url.com");

menu loads here and all is fine, but since i can’t get “shouldOverrideUrlLoading” to work using super.loadurl, i’m trying to launch the app straight into webview.

mwebview.loadurl("http://url.com");
does work, but if i push the menu button, it will crash.

my menu is made programmatically like so :

 @Override
        public boolean onCreateOptionsMenu(Menu menu) {
        //Menu that appears when menu button is pressed on device
         Menu m_menu = menu;
         m_menu.add(Menu.NONE, Menu.FIRST+6, 0, "Hjem");
         m_menu.add(Menu.NONE, Menu.FIRST+7, 0, "Om");
         m_menu.add(Menu.NONE, Menu.FIRST+5, 0, "Avslutt");
         return super.onCreateOptionsMenu(menu);
        }

Heres my activity:

 @Override
        public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        super.setBooleanProperty("loadInWebView", true); 
        mWebView = (WebView) findViewById(R.id.webview);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.getSettings().setBuiltInZoomControls(false);
        mWebView.requestFocusFromTouch();
        mWebView.setWebViewClient(new HelloWebViewClient());
        mWebView.setWebChromeClient(new WebChromeClient());

           getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
            WindowManager.LayoutParams.FLAG_FULLSCREEN | 
            WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
            super.setIntegerProperty("splashscreen", R.drawable.splash);
            super.setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            super.loadUrl("http://www.url.com/app/index");
//mWebView.loadurl("url");
            }
        private class HelloWebViewClient extends WebViewClient {
             @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }

        }

Heres the error in catlog :

03-03 10:00:26.893: E/AndroidRuntime(350): FATAL EXCEPTION: main
03-03 10:00:26.893: E/AndroidRuntime(350): java.lang.NullPointerException
03-03 10:00:26.893: E/AndroidRuntime(350):  at com.phonegap.DroidGap.postMessage(DroidGap.java:943)
03-03 10:00:26.893: E/AndroidRuntime(350):  at com.phonegap.DroidGap.onCreateOptionsMenu(DroidGap.java:1374)
03-03 10:00:26.893: E/AndroidRuntime(350):  at blogreel.app.HelloAppActivity.onCreateOptionsMenu(HelloAppActivity.java:44)
03-03 10:00:26.893: E/AndroidRuntime(350):  at android.app.Activity.onCreatePanelMenu(Activity.java:2148)
03-03 10:00:26.893: E/AndroidRuntime(350):  at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:305)
03-03 10:00:26.893: E/AndroidRuntime(350):  at com.android.internal.policy.impl.PhoneWindow.onKeyDownPanel(PhoneWindow.java:550)
03-03 10:00:26.893: E/AndroidRuntime(350):  at com.android.internal.policy.impl.PhoneWindow.onKeyDown(PhoneWindow.java:1192)
03-03 10:00:26.893: E/AndroidRuntime(350):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1648)
03-03 10:00:26.893: E/AndroidRuntime(350):  at android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:2471)
03-03 10:00:26.893: E/AndroidRuntime(350):  at android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2441)
03-03 10:00:26.893: E/AndroidRuntime(350):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1735)
03-03 10:00:26.893: E/AndroidRuntime(350):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-03 10:00:26.893: E/AndroidRuntime(350):  at android.os.Looper.loop(Looper.java:123)
03-03 10:00:26.893: E/AndroidRuntime(350):  at android.app.ActivityThread.main(ActivityThread.java:4627)
03-03 10:00:26.893: E/AndroidRuntime(350):  at java.lang.reflect.Method.invokeNative(Native Method)
03-03 10:00:26.893: E/AndroidRuntime(350):  at java.lang.reflect.Method.invoke(Method.java:521)
03-03 10:00:26.893: E/AndroidRuntime(350):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-03 10:00:26.893: E/AndroidRuntime(350):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-03 10:00:26.893: E/AndroidRuntime(350):  at dalvik.system.NativeStart.main(Native Method)

So im asking :
Any way to make my menu work when loading straight into webview?
Or to make “Shouldoverrideurl” work on all urls when using “super.loadurl”

edit
Have to add that the first page super.loadurl loads does work. the specified url has links that, when clicked, redirects within the same webview. however, the second page’s links will trigger in a new browser.

Any pointers are greatly appreciated 🙂

  • 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-30T18:53:02+00:00Added an answer on May 30, 2026 at 6:53 pm

    This is how I have managed to add menu button support to PhoneGap and regular Android Webview projects

    //basic menu button support
    @Override
    public boolean onCreateOptionsMenu(Menu menu) 
    {
        super.onCreateOptionsMenu(menu);
        MenuItem item = menu.add("Refresh");
        item = menu.add("Quit");
        return true;
    }
    
    //handle menu item selection
    public boolean onOptionsItemSelected(MenuItem item)
    {
        if (item.hasSubMenu() == false)
        {
            if("Quit"==item.getTitle()) {
                finish();
            }
            if("Refresh"==item.getTitle()) {
               super.loadUrl("file:///android_asset/www/index.html");
            }
        }
        return true;
    }
    
    • 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’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
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,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from

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.