Hi Team,
I am doing one application(phone gap+android) for that I have to check internet "online" or "offline" ,for the way I followed phone gap API documentation,but for getting response its taking long time(few minutes).
how can I get immediate response from online and offline events. Please give solution for this.
Please tell me solution for this.
please below my code:
function init() {
document.addEventListener("deviceready", onDeviceReady, true);
}
function onDeviceReady(){
document.addEventListener("online", onOnline, false);
document.addEventListener("offline", onOffline, false);
}
function onOnline() {
alert("yes-onOnline");
}
function onOffline() {
alert("yes-onOffline");
}
Thank you,
Siva.
I am doing one application(phone gap+android) for that I have to check internet "online" or "offline" ,for the way I followed phone gap API documentation,but for getting response its taking long time(few minutes).
how can I get immediate response from online and offline events. Please give solution for this.
Please tell me solution for this.
please below my code:
function init() {
document.addEventListener("deviceready", onDeviceReady, true);
}
function onDeviceReady(){
document.addEventListener("online", onOnline, false);
document.addEventListener("offline", onOffline, false);
}
function onOnline() {
alert("yes-onOnline");
}
function onOffline() {
alert("yes-onOffline");
}
Thank you,
Siva.
- 62 Posts
- 0 Reply Likes
Posted 8 years ago
- 1911 Posts
- 199 Reply Likes
The offline/online events only fire when the state changes - when your app goes from offline to online, or vice versa.
If you need to find out whether your app is on or offline immediately, check navigator.network.connection.type after deviceready has fired
http://docs.phonegap.com/en/2.1.0/cor...
If you need to find out whether your app is on or offline immediately, check navigator.network.connection.type after deviceready has fired
http://docs.phonegap.com/en/2.1.0/cor...
- 62 Posts
- 0 Reply Likes
- 2 Posts
- 0 Reply Likes
Is there any reason why navigator.network does not return an object?I am using it after deviceready to retrieve navigator.network.connection.type but I am getting a:
"Cannot read property 'connection' of undefined "
error.
Any clue?
Thanks!!
"Cannot read property 'connection' of undefined "
error.
Any clue?
Thanks!!
- 1911 Posts
- 199 Reply Likes
Iván: that API has changed, and you should be referring to navigator.connection. Please see the documentation here:
http://docs.phonegap.com/en/2.2.0/cor...
http://docs.phonegap.com/en/2.2.0/cor...
- 70 Posts
- 0 Reply Likes
Hi ,
navigator.online is not working on mobile why??
Please anybody give some idea..
navigator.online is not working on mobile why??
Please anybody give some idea..
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
That attribute is not supported (correctly) everywhere. You should use the network connection information plugin.
https://github.com/apache/cordova-plu...
Use the online and offline events as described in the plugin docs.
https://github.com/apache/cordova-plu...
Use the online and offline events as described in the plugin docs.
- 70 Posts
- 0 Reply Likes
I wanted to check whether my device is connected with internet or not....
I need to check using phonegap ....
I need to check using phonegap ....
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
Yes, well, use that plugin. It will give that information.
You can use it to either plainly check for a connection, or react to connection status changes instantly.
You can use it to either plainly check for a connection, or react to connection status changes instantly.
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
*sigh*
No, you don't.
Look, you asked 45 minutes ago in a 3-year-old thread, which is bad enough. By now, you could have referenced that plugin, coded the required one-liner and rebuilt. Twice.
Why don't you just do that?
No, you don't.
Look, you asked 45 minutes ago in a 3-year-old thread, which is bad enough. By now, you could have referenced that plugin, coded the required one-liner and rebuilt. Twice.
Why don't you just do that?
- 70 Posts
- 0 Reply Likes
<!DOCTYPE html SYSTEM>
Cordova Online Example
I got an error in this statement ( states[Connection.UNKNOWN] = 'Unknown connection';)
Cordova Online Example
I got an error in this statement ( states[Connection.UNKNOWN] = 'Unknown connection';)
Related Categories
-
PhoneGap Framework
- 2926 Conversations
- 61 Followers



