Forum Xamarin.Forms

CrossConnectivity on Android

I'm having the strangest problem. I use James Montemagno's Cross Connectivity plugin. I use it to check connectivity to the web like so:
if (!CrossConnectivity.Current.IsConnected)
return null;

On iOS it simply works. On Android, when I debug actively either to emulator or device, it works. But when I stop debugging and just run the app, it stops seeing the my wifi and returns false. What could possible cause that?
Thanks in advance!! I am almost there.


  • GaryBeasleyGaryBeasley USMember ✭✭

    I commented out all the Cross Connectivity code and it was able to hit my web service no problem. Definitely something in the plugin. Strange.

  • LoriLalondeLoriLalonde CAInsider, University, Developer Group Leader ✭✭✭

    Have you added the necessary permissions to the AndroidManifest.xml file as James' mentioned on the project page:

    "Android: You must request ACCESS_NETWORK_STATE permission to get the network state You must request ACCESS_WIFI_STATE to get speeds"

  • GaryBeasleyGaryBeasley USMember ✭✭

    Thanks! Yes I did.
    I just found the culprit. The CrossConnectivity.Current.IsConnected functionality works whether debugging or just running and on iOS and Android. The problem was with IsReachable(). I took out the "https://" and just used the www.ccserver??.com instead and that solved it. Strange, only on Android did that matter, and not while debugging but when just running.

Sign In or Register to comment.