cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Bowser <bows...@gmail.com>
Subject Re: [Android] - State, Plugins and the Android Lifecycle
Date Thu, 08 Nov 2012 17:28:10 GMT
Here's how it plays in WebKit.  Below is an example of a test activity:

public class cordovaExample extends DroidGap
{

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        super.setBooleanProperty("keepRunning", false);
        super.init();

        if(savedInstanceState != null)
        {
            Log.d("Test Application", "Restoring the state");
            this.appView.restoreState(savedInstanceState);
        }
        else
        {
            super.loadUrl("file:///android_asset/www/index.html");
        }
    }



    protected void onSaveInstanceState(Bundle outState)
    {
        super.onSaveInstanceState(outState);
        this.appView.saveState(outState);
    }
}

In the example above, the savedInstanceState is being passed in.  This
is the same bundle that would hold the result from an activity.  We
then run restore state on the WebView, which allows us to get our
history, HTML and Javascript back to where it was.  This runs through
all the normal loading in the WebView, but this will crash on Cordova
currently because onResume assumes that we have a WebView that's
already populated, which is no longer the case in this scenario.

I did some work on it, and I'm having trouble getting the bridge
working on the resume.  Still, we have to encapsulate this and hide
this from the average Cordova developer so it just works.  I think
this will require a refactor to do it, and I think this might break
some things that people may be using.

Joe

Mime
View raw message