Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User oxidative's Avatar
    Join Date
    Apr 2008
    Posts
    35
    I have a widget that is added to the homescreen. The widget has a fullscreen view in which you can check for new versions of the widget. It does an async. XMLHttpRequest to connect to my webserver in order to fetch the current version info.

    This all works fine (I've added the required permission to Info.plist). However the connection is never closed. Either the wireless or the gsm network connection icon will always be visible after doing a new version check. As soon as I remove the widget from the homescreen again, the connection is properly closed down.

    How can I tell the phone to close the connection it opened for my widget?

    My code looks like this:

    Code:
    var reqV = null; 
    
    function checkForUpdate()
    {
    	// asynch XHR to server url
    	reqV = new XMLHttpRequest();
    	reqV.onreadystatechange = checkForUpdateCallback;
    	document.getElementById("updateDiv").innerHTML = getLocalizedText("update.checking");
    	reqV.open("GET", versionURL, true);
    	reqV.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" ); // disable caching
    	reqV.send(null);
    }
    
    function checkForUpdateCallback()
    { 
    	if (reqV.readyState == 4) {
    		if (reqV.status == 200) {
    			var resultXml = reqV.responseText;
    			if (resultXml) {
    				var div = document.getElementById("tmp");
    				div.innerHTML = resultXml;
    				var newVersion = div.getElementsByTagName('version')[0].innerHTML;
    				var newVersionURL = div.getElementsByTagName('url')[0].innerHTML;
    				div.innerHTML = "";
    				if (version != newVersion) {
    					document.getElementById("updateDiv").innerHTML = getLocalizedText("update.download").replace(/%1/, newVersion).replace(/%2/, newVersionURL);
    				}
    				else {
    					document.getElementById("updateDiv").innerHTML = getLocalizedText("update.nonewversion");
    				}
    			}
    		}
    		else {
    			document.getElementById("updateDiv").innerHTML = getLocalizedText("update.error") + reqV.status + " " + reqV.responseText + ", " + getAllResponseHeaders();
    		}
    	}
    	else
    		document.getElementById("updateDiv").innerHTML = getLocalizedText("update.error") + reqV.readyState + ", " + reqV.status + " " + reqV.responseText + ", " + getAllResponseHeaders();
    	delete reqV;
    	reqV = null;
    }

  2. #2
    Nokia Developer Moderator isalento's Avatar
    Join Date
    Jun 2008
    Location
    Tampere
    Posts
    831
    Hi,

    I don't think there is anything to do in WRT side to close the connection. Keeping the connection open must be a platform functionality. Have to admit that I don't exactly know if it is intended or not. It sort of makes sense to keep connection alive in case there is consecutive requests, as it takes long to initiate connection.

    Br,
    Ilkka

  3. #3
    Registered User oxidative's Avatar
    Join Date
    Apr 2008
    Posts
    35
    I just noticed that you get the same behaviour when using the phone's webbrowser. The network connection will stay forever after closing the browser. I don't think this is a very battery friendly method of handling internet connections...

Similar Threads

  1. How to add widget to homescreen on N97
    By yhhighest in forum Symbian C++
    Replies: 7
    Last Post: 2011-07-28, 19:28
  2. Homescreen widget: Error occured. Widget removed
    By _yarik_ in forum Symbian User Interface
    Replies: 2
    Last Post: 2011-02-12, 22:17
  3. Moving from standard widget to homescreen widget
    By Elsterap in forum Symbian Web Runtime
    Replies: 1
    Last Post: 2009-08-06, 04:45
  4. what is a homescreen widget ?
    By yosr eman in forum General Development Questions
    Replies: 4
    Last Post: 2009-03-04, 14:54

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved