Using sessionStorage in a webview

by hansamann » Wed, 16 Jun 2010 04:55:02 GMT

Sponsored Links
 Hi all,

I am trying to set a flag for the current session in the webview. I
enabled the DOM storage API:


In my HTML page, loaded from the assets directory, I then execute a
small piece of javascript like this:

                        if (!sessionStorage.flag)
                                        //do stuff once per session
                                        sessionStorage.flag = true;
                                //do nothing

Problem: the //do stuff once per session section is always entered, it
seems the flag is set but each orientation change reloads the complete
HTML page and all the session state is completely lost.

I wanted to use the flag to execute a piece of code once, and even if
the user turns the device, (in which the HTML page seems to be
reloaded, for whatever reason), not execute the code again.

Any ideas?
Is this just broken becaus I load the HMTL resource from the local
package, from the assets directory?



Other Threads

1. ListView and ListAdapter

I am trying to use ListView and ListAdapter.  If I create a simple
Android project and add a ListView as the content view, and set it's
adapter to my adapter based on ListAdapter, everything seems to work.
My ListAdapter's 'getCount' is called, and I return 3, my
'getViewTypeCount' is called and I return 1, my 'getItemType' is
called and I return 0, and for each item, my 'getView' is called and I
return a TextView.  Everything works, and the list is displayed with 3

Now if I try and do the same thing in a more complicated environment,
it does not work.  My 'getCount', 'getViewTypeCount' and 'getItemType'
methods are called, but the 'getView' method is never called and the
ListView appears empty.

Now I know that I must be doing something wrong in the more
complicated case, but I cannot see what it is. The code is really too
involved to post here, but I was hoping that someone could give me
some ideas as to why my 'getView' is never called even though I return
3 from my 'getCount' method.



2. Can I mark a Preference in xml and detect the mark inside its containing PreferenceActivity?

I want most, but not all, of my non-CheckBox Preferences to show their
current values as summaries when displayed in a PreferenceActivity.
I've implemented this by overriding onSharedPreferenceChanged() in my
PreferenceActivity subclass.  For each SharedPreferences instance
passed in, onSharedPreferenceChanged() checks if the key is in a
hard-coded list and if so sets the summary from the current value of
the Preference.

It's a gross violation of OOP principles, but it works.

What I'd rather do is somehow mark individual Preference subclasses in
my xml file as desiring that behaviour.  I've read how to create
xml tags, but I can't figure out how to get at them from inside a
PreferenceActivity.  It seems the only access to a View's AttributeSet
comes in its constructor, and I don't have access to that since I'm
only overriding the Activity that contains these Views.

I could accomplish the same thing by overriding every Preference
subclass I use, adding nothing but an 'implements SomeEmptyInterface'
statement.  I'd then test inside onSharedPreferenceChanged() whether
instances passed in implement that interface.  But adding a simple xml
attribute seems much cleaner.

Is it possible?




3. Can I use code to enable the GPS service?

4. Can I use code to enable the GPS service?

5. How do I draw onto an app using an XML layout?

6. Pejing Cak Nurfat

7. Froyo:* : works on Emulator?