(Difference between revisions)

Storing state on exit in Symbian Web Runtime

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Automated change of category from Browsing to Browser. (Ontology Change))
hamishwillee (Talk | contribs)
m (Bot change of links to internal format.)
Line 48: Line 48:
For a complete example, see: [http://wiki.forum.nokia.com/index.php/File:StoreStateOnExit.zip StoreStateOnExit.zip][[Category:Technical Solution]][[Category:JavaScript]]
For a complete example, see: [[:File:StoreStateOnExit.zip|StoreStateOnExit.zip]][[Category:Technical Solution]][[Category:JavaScript]]

Revision as of 06:36, 19 May 2011


Article Metadata
Tested with
Devices(s): Nokia N97, Nokia N97 mini
Platform(s): S60 5th edition
Keywords: widget.onexit
Created: (23 Dec 2009)
Last edited: hamishwillee (19 May 2011)


In some situations, it might be necessary to store the widget state on exit. One of these use cases is storing the last shown full screen view before the widget is minimised to the home screen by pressing the Exit key. The same view can then be shown to the user the next time the widget is maximised.


To implement this you will need to:

  • detect when the widget has been closed
  • store the state on exit and load state information when the widget is started.

The closing of a widget can be detected by defining an event handler for the widget.onexit event.

 widget.onexit = function() {
// store current view

widget.onexit is fired every time a widget is closed, just before the last onhide event.

For storing the state, setPreferenceForKey can be used. At startup, the last stored state can be loaded using preferenceForKey.

 var lastActiveFSView;
widget.onexit = function() {
if (lastActiveFSView) {
widget.setPreferenceForKey(lastActiveFSView, "lastActiveFSView");
window.onload = function() {
lastActiveFSView = widget.preferenceForKey("lastActiveFSView");

For a complete example, see: StoreStateOnExit.zip

88 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.