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

  • Home
  • SEARCH
  • 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 7445839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:08:17+00:00 2026-05-29T12:08:17+00:00

I have a webview and I load some html5+js into it. My webapp is

  • 0

I have a webview and I load some html5+js into it. My webapp is extremely data intensive. Using the state functions, I am able to get back to the correct ‘page’ I am supposed to be on after orientation change, however my webapp is in peril because all my javascript variables have been reset as well.

Is there a method to have all my javascript variables saved and restored on webview orientation changes? What about values entered into form text boxes?

==================

I’ve made some progress on this. In my JS, I have a hook that is called requestState(); When this function is called, it sends all my JS variables to the android / java side via JS Interface.

On the Java side I persist this information using getLastNonConfigurationInstance and onRetainNonConfigurationInstance. I’ve tested the output and it does indeed save all my JS variables into my object in Java right before the activity state is changed on orientation alterations.

The issue is getting back to where I am supposed to be. I have a function in my JS which functions the opposite of requestState(); called setState(input);. This function is invoked from the Android side by using mywebview.loadUrl( "javascript:setState(" + jsonStr + ")" );. I do this at the end of my onCreate, after deflating the webview and calling wv.restoreState(savedInstanceState);.

What I have noticed though is that setState has not been defined at the time of me calling it! In fact, none of my JS scripts are ready to be called or even exist / are found at the end of my activity’s onCreate function. To test my sanity, I tried mywebview.loadUrl( "javascript:alert(" + jsonStr + ")" ); and I indeed saw what I expected to see — the alert with all my variable values in it. However I noticed that the page itself hadn’t rendered before the alert came up. How should I go about fixing this issue?

  • 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-29T12:08:18+00:00Added an answer on May 29, 2026 at 12:08 pm

    Don’t waste your time guys. After much peril, I’ve decided to go with html5 local storage, which I guess most people must use anyway since there is no resolution to the above problem.

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

Sidebar

Related Questions

I have Activity with some data displayed in WebView that I load with WebView#loadDataWithBaseURL
I am using a Webview and some css3 to load an image and have
I have various pieces of generated HTML/JS that I load into Activity with WebView#loadDataWithBaseURL.
I have a webview and am trying to load simple UTF-8 text into it.
I have a webview in my iPhone application, and I also have some html
I have a WebView. I'd like to show some page from my server, but
I have an Activity which is basically a big webview with some other buttons.
I have a WebView. I want to load a local HTML file called helloworld.html.
In my activity I have some links that when user click on it, WebView
Hi I am trying to load a webview that uses javascript and html5. However,

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.