"Online" and "Offline" events doesn't give any response...

  • 1
  • Problem
  • Updated 8 years ago
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 I didn't get response from that.

Please tell me solution for this.

Thank you,
Siva.
Photo of gudluri siva

gudluri siva

  • 62 Posts
  • 0 Reply Likes

Posted 8 years ago

  • 1
Photo of Amir

Amir

  • 8261 Posts
  • 263 Reply Likes
Hi Gulduri

Did the deviceReady event fires? You can test with an alert box inside it's callback function.

Thanks
-Amir
Photo of gudluri siva

gudluri siva

  • 62 Posts
  • 0 Reply Likes
Hi Amir,

Thank you for your kind response.

I got the response from online event, 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.

Thank you,
Siva.
Photo of Amir

Amir

  • 8261 Posts
  • 263 Reply Likes
Hi Siva

Where did you test the app? simulator or device? Have you try that out on different device?

You can share part of the code the code so I can have quick look into it.

Thanks
-Amir
Photo of gudluri siva

gudluri siva

  • 62 Posts
  • 0 Reply Likes
HI Amir,

I checked with both emulator and android device.
Please find my java script code below, please tell solution for getting the response.

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.
Photo of Amir

Amir

  • 8261 Posts
  • 263 Reply Likes
The code look good. You should not get into trouble with it. Not sure what other things causing the delay.

By the way, this is beyond what I could offer to support. We are mainly discuss about Build over here but someone hopefully able to answer your question soon.

Anyway, you might want to ask the same at our framework community forum. You'll find lot of good resources over there. Below is the link:

http://groups.google.com/group/phonegap.

Cheers
-Amir
Photo of gudluri siva

gudluri siva

  • 62 Posts
  • 0 Reply Likes
Hi Amir,

Thank you very much.

Thank you,
Siva.