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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:39:13+00:00 2026-06-16T13:39:13+00:00

I have an activity containing a WebView: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); webView

  • 0

I have an activity containing a WebView:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    webView = new WebView(this);
    setContentView(webView);
    webView.getSettings().setUserAgentString(MY_CLIENT);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.getSettings().setUseWideViewPort(true);
    webView.setWebViewClient(new MyWebViewClient());
}

My activity defines 2 menu items, which shall result in loading of 2 different URLs URL1 and URL2:

public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_url1:
        webView.loadUrl(URL1);
        return true;
    case R.id.menu_url2:
        webView.loadUrl(URL2);
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

However, an URL is only loaded for the 2nd time the according menu item is selected. Setting breakpoints in MyWebViewClient.onPageStarted() and MyWebViewClient.onPageFinished() shows that on the first click, onPageFinished() is called, but the url is not loaded into the WebView. On the 2nd click, onPageStarted() is invoked, followed by two invocations of onPageFinished(), and the url is loaded into the WebView. If I then try to load the other URL, the process starts over, and again two clicks are needed.

My target Android SDK is 17, min SDK is 8. I’m testing on a Nexus 7.

What do I have to do do make the WebView load an URL for the first click? And how can I debug such issues?

  • 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-16T13:39:14+00:00Added an answer on June 16, 2026 at 1:39 pm

    It looks like the problem is related to the URLs I’m trying to load – other URLs work just fine. Since for the ones I’m trying to load, I always have to perform two calls of loadURL(), I’m now just doing exactly that in the code – weird workaround, but works so far. I have to look into the URLs, thought…

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

Sidebar

Related Questions

Suppose I have a tab delimited file containing user activity data formatted like this:
I have an Activity containing an ImageView and I'd like to allow the User
I have Activity with ListView inside it and in the onCreate method of the
I have an activity with the following layout. So in this screen, initally the
I have an activity in whose onCreate method an Init function is called (the
Let's say I have an Activity which displays a View containing a TextView .
I have a UIPicker with 3 components containing numeric values, this allows the user
I have a android app project in Eclipse, and in my activity containing a
I have an Activity which is basically a big webview with some other buttons.
I have an Activity containing a ListView based on SimpleCursorAdapter and a button. When

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.