Playmaker Forum

PlayMaker Help & Tips => Android Help => Topic started by: djaydino on April 23, 2015, 10:55:35 PM

Title: Check internet Action not working well on android
Post by: djaydino on April 23, 2015, 10: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
Title: Re: Check internet Action not working well on android
Post by: jeanfabre on May 21, 2015, 06: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
Title: Re: Check internet Action not working well on android
Post by: Weedsh on February 11, 2016, 10: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();
}