Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We are updating our Terms of Service for all Unity subscription plans, effective October 13, 2022, to create a more streamlined, user-friendly set of terms. Please review them here: unity.com/legal/terms-of-service.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice
  4. Join us on Thursday, September 29, for a day with Unity's SRP teams here on the forum or on Reddit, and discuss topics around URP, HDRP, and the Scriptable Render Pipeline in general.
    Dismiss Notice

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:
    29,715
    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:
    29,715
    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:
    422
    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