playMaker

Author Topic: Check internet Action not working well on android  (Read 1158 times)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 2254
    • View Profile
    • jinxtergames
Check internet Action not working well on android
« on: April 23, 2015, 07:55:35 PM »
Check internet does not seem to work very well on android device :

when i am offline from a fresh restart it gives offline correctly,
then i go online and start the game and it gives online correctly.

but then when i disconnect the internet and start the game again it still gives online as result... i tried editing the url, changed it to my own website, but gives the same result....

greetings,

Dino
Modify message

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12342
  • Official Playmaker Support
    • View Profile
Re: Check internet Action not working well on android
« Reply #1 on: May 21, 2015, 03:46:47 AM »
Hi,

Where did you get this action?

 typically, you need to bypass the cache ( which is likely the issue), and so everytime you check, the url you use to access internet and check the  result must be different always.

this is done by appending a dummy url variable like &time=123123

where 123123 is the current time, and so you won't hit any caching issue.

Bye,

 Jean

Weedsh

  • Playmaker Newbie
  • *
  • Posts: 24
    • View Profile
Re: Check internet Action not working well on android
« Reply #2 on: February 11, 2016, 08:02:17 AM »
this code works better for me.

Code: [Select]
try
{
//Dns.GetHostEntry("www.google.com");
using (var client = new WebClient())
{
using (var stream = client.OpenRead("http://www.google.com"))
{
Fsm.Event(internetIsOn);
}
}
Finish();
}
catch
{
Fsm.Event(internetIsOff);
Finish();
}