Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by brainzizizi · Sep 10, 2011 at 11:06 AM · androidwwwinternetping

Detecting internet availability on Android

Application.internetReachability always returns NetworkReachability.NotReachable on my Android 2.1. Works as expected in Editor. I also tried using the Ping class to detect internet availability using the following C# code.


 IEnumerator CheckConnection()
 {
     const float timeout = 10f;
     float startTime = Time.timeSinceLevelLoad;
     Ping ping = new Ping("199.59.148.82");
         
     while (true)
     {
         internetAvailableText = "Checking network...";
         if (ping.isDone)
         {
             internetAvailableText = "Network available.";
             yield break;
         }
         if (Time.timeSinceLevelLoad - startTime > timeout)
         {
             internetAvailableText = "No network.";
             yield break;
         }
 
         yield return new WaitForEndOfFrame();
     }
 }


It always timed out. WWW class works as expected. Anyone had luck detecting internet access on Android?

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image jparkPULSEWORKS · Nov 27, 2012 at 02:38 PM 0
Share

Any resolution on this bug?

avatar image brainzizizi · Nov 27, 2012 at 04:50 PM 0
Share

Looks like it's fixed in 4.0 and won't be fixed in 3.5.6 as far as I'm concerned.

avatar image kUr4m4 · Jan 13, 2014 at 02:31 PM 0
Share

Remember to use .net 2.0 and not the "subset" version.

7 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by oliverdb · Oct 03, 2011 at 12:12 PM

I have the same error. Its a bug in Unity

Comment
Add comment · Show 7 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image liszto · Nov 07, 2012 at 09:39 AM 0
Share

someone report it ?

avatar image brainzizizi · Nov 07, 2012 at 09:44 AM 0
Share

I haven't tested it on the new Unity, so maybe it's fixed. If you verified it still doesn't work as expected, file a bug report.

avatar image liszto · Nov 07, 2012 at 09:49 AM 0
Share

The new Unity for you is 4.0 ? or last 3.5.6 ?

avatar image brainzizizi · Nov 07, 2012 at 09:56 AM 0
Share

I meant Unity 3.5.6, Unity 4 is still beta AFAI$$anonymous$$.

avatar image liszto · Nov 07, 2012 at 10:11 AM 0
Share

I'm under Unity 3.5.6 and still the bug. $$anonymous$$aybe unity 4 is still beta but free beta so maybe I can test it tonight. Hope it's fixed -_-

Show more comments
avatar image
0

Answer by hotshot03 · Apr 03, 2013 at 08:06 AM

IEnumerator CheckInternet(){ WWW internet = new WWW("www.google.com"); yield return internet; if(internet.error!=null) isInternet=false; else{ isInternet=true; }
}

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image naglers · Oct 30, 2013 at 03:05 PM 0
Share

this doesn't work for me on Android

avatar image
0

Answer by eriQue · Sep 15, 2011 at 08:15 AM

Is your application perhaps missing the "android.permission.INTERNET" permission in the manifest? Unity should autodetect any usage of networking component but perhaps it fails for some reason..

You can inspect the permissions assigned to the application by looking under Settings > Application > Manage applications, on your device.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image brainzizizi · Sep 15, 2011 at 08:59 AM 0
Share

Says: This application can access the following on your phone: Network communication, full internet access.

Did you manage to get Application.internetReachability and/or Ping to work on Android?

avatar image oliverdb · Oct 24, 2011 at 07:56 PM 0
Share

I have the same issue as brainziziz

avatar image liszto · Nov 07, 2012 at 07:53 AM 0
Share

Some find a solution to this cause I did this on my Android device :

http://pastebin.com/CDCW7haY

And it never finds Internet connection é_è

avatar image
0

Answer by naglers · Jan 13, 2014 at 03:46 PM

I found a solution for my android app. Check out the Unity Answer here: http://answers.unity3d.com/questions/567497/how-to-100-check-internet-availability.html

instead of using the WWW class I use System.Net and HttpWebRequest this way you can check for more than just web availability. You get 3 levels of connection checking:

1) No connection

2) Redirected (this was important for me because if you are connecting to the internet at a college or hotel, they need you to sign in before using the internet which means you'll get a positive ping / check but you really don't have internet yet because you can't send anything to the site you actually want)

3) Reached the correct page

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by tonic · Jul 04, 2014 at 02:02 PM

(Adding a comment to an old posting in case somebody finds this using search...)

I have made an easy asset called Internet Reachability Verifier for Unity, which implements a technique called "captive portal detection", but still does it only using the built-in WWW class.

Using it you will know if internet is truly reachable or if you're just hitting e.g. a login page, like mentioned at the point (2) above.

More info here: http://j.mp/IRVUN

Edit: That asset also jumps through the hoops needed to support Android 9.0+ Network Security Config.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Ping make my android app crash if no internet connection 1 Answer

Best way to check internet connectivity (Android + iOS) 4 Answers

How can i do youtube video player from video url for Android devices ? 0 Answers

Is WWW class usable in Android platform? 1 Answer

Unity download audio 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges