Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice
  2. Welcome to the Unity Forums! Please take the time to read our Code of Conduct here to familiarize yourself with the rules and how to post constructively.

Application.internetReachability

Discussion in 'Editor & General Support' started by Futurebear, Nov 11, 2011.

  1. Futurebear

    Futurebear

    Joined:
    Jan 11, 2010
    Posts:
    97
    After searching for a while I can not seem to find out how to detect whether or not I am connected to the internet on android.

    Application.internetReachability or the iOS network detect work for android. I can detect network connection on iOS and PC build, just not android. The only help I found on answers and here is to make sure that you have permission set on the android manifest for network. I have checked my manifest and I do have it enabled, as well as going into the application settings on the android to make sure I have network permissions. There has to be another quick way besides pining random websites.

    Any help would be appreciated. Thanks.
     
  2. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    28,394
    I find this does not work on iOS as expected. I decided to work around it by using www class to see if it could reach google or not.
     
  3. Futurebear

    Futurebear

    Joined:
    Jan 11, 2010
    Posts:
    97
    That will not work in this instance. I thought of that.
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    What kind of instance would that be where reachability would yield any information that a simple WWW test doesn't?
     
  5. Futurebear

    Futurebear

    Joined:
    Jan 11, 2010
    Posts:
    97
    It would work technically. Since I want to test a connection every minute or so, using some one else's server to ping or connect to isn't a very good idea.Just need a way to test connectivity on the device like Application.internetReachability.
     
  6. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    28,394
    Well file a bug because Application.InternetReachability 100% does not work very well on iOS, particularly on ipad and wifi, if you pull wifi out etc.

    But www class will indeed throw a meaningful error :) in fact if you can't reach google you can't reach anything on wifi really.
     
  7. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    420
    To truly know you're online, you need to implement "captive portal detection", to know if you're e.g. hitting a public WiFi login page. So just checking Application.internetReachability or doing a Ping to some address doesn't guarantee you can successfully make connections or make WWW requests.

    I have made an easy asset called Internet Reachability Verifier. It keeps you up-to-date whether you have verified internet access (WWW requests can be done). Works with desktop and mobile platforms (and if you for some reason think you need to use it with web player plugin, that's also possible if you use the self-hosted custom way).
    More info here: http://j.mp/IRVUN
     
unityunity