From callback-dev-return-7689-apmail-incubator-callback-dev-archive=incubator.apache.org@incubator.apache.org Thu May 31 19:03:24 2012 Return-Path: X-Original-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 06CE2CE73 for ; Thu, 31 May 2012 19:03:24 +0000 (UTC) Received: (qmail 42056 invoked by uid 500); 31 May 2012 19:03:23 -0000 Delivered-To: apmail-incubator-callback-dev-archive@incubator.apache.org Received: (qmail 41979 invoked by uid 500); 31 May 2012 19:03:23 -0000 Mailing-List: contact callback-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-dev@incubator.apache.org Received: (qmail 41682 invoked by uid 99); 31 May 2012 19:03:23 -0000 Received: from issues-vm.apache.org (HELO issues-vm) (140.211.11.160) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 31 May 2012 19:03:23 +0000 Received: from isssues-vm.apache.org (localhost [127.0.0.1]) by issues-vm (Postfix) with ESMTP id 2DB1A142859 for ; Thu, 31 May 2012 19:03:23 +0000 (UTC) Date: Thu, 31 May 2012 19:03:23 +0000 (UTC) From: "Aurelien MERCIER (JIRA)" To: callback-dev@incubator.apache.org Message-ID: <692456953.23196.1338491003189.JavaMail.jiratomcat@issues-vm> In-Reply-To: <877024904.13725.1338334463470.JavaMail.jiratomcat@issues-vm> Subject: [jira] [Commented] (CB-842) Offline event fired without special reasons MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CB-842?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13286835#comment-13286835 ] Aurelien MERCIER commented on CB-842: ------------------------------------- Tried on Nexus one HTC with Cordova 1.7 (this code include my fix to prevent Offline method to be executed when the navigator is online): community.js: function onDeviceReady() { try { jive.profile.onDeviceReadyInit(); } catch (e1) { console.log("ERROR in onDeviceReady"); console.log(e1); } document.addEventListener("offline", onOffline, false); [...] } function onOffline(event) { if (this.isOfflineAfterOfflineEvent()) { document.removeEventListener("offline", onOffline, false); $.mobile.activePage.simpledialog({ width: 'auto', mode : 'bool', prompt : 'Network Error', subTitle: 'Your device must have a working network connection to use this application.', useModal: true, buttons : { 'Close': { click: function() {}, icon: "delete", theme: "j" } } }); } } function onOffline(event) { if (this.isOfflineAfterOfflineEvent()) { document.removeEventListener("offline", onOffline, false); $.mobile.activePage.simpledialog({ width: 'auto', mode : 'bool', prompt : 'Network Error', subTitle: 'Your device must have a working network connection to use this application.', useModal: true, buttons : { 'Close': { click: function() {}, icon: "delete", theme: "j" } } }); } } utils.js: jive.mobile.util = $.extend( jive.mobile.util, { getBaseURLForHref: function() { return jive.mobile.nativeapp.baseurl; }, isOfflineAfterOfflineEvent: function () { //FIXME /CB-842 var res = false; if ((navigator.network && navigator.network.connection.type !== Connection.NONE) || (navigator.onLine && typeof navigator.onLine == 'boolean' && navigator.onLine === false)) { res = true; } return res; } }); > Offline event fired without special reasons > ------------------------------------------- > > Key: CB-842 > URL: https://issues.apache.org/jira/browse/CB-842 > Project: Apache Cordova > Issue Type: Bug > Components: Android > Affects Versions: 1.7.0 > Reporter: Aurelien MERCIER > > The event is fired whereas I'm connected to wifi. Putting some logs in offline method, I see that navigator.network.connection.type is NONE and navigator.onLine is true. > Ps: it seems it appears after loading a page... > Right now I've added extra test in offline method to be sure it has been called whereas there is really no connection available. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira