1

Is there a way to programmatically determine if a user's Android device is connecting to the Internet via cellular (3G/EDGE) or it has a Wi-Fi connection for Unty3d Android game?

Is there any Unity3d API to do this kind of job? I've been looking over the internet and found few suggestion to ping some web site to determine if the phone does have an internet connection. But it solves only one part of the issue.

In addition to knowing if the phone has an internet connection, I would also like to know what kind of internet it is.

Daler
  • 1,205
  • 3
  • 18
  • 39

2 Answers2

1

Yes, Unity has its own Network Reachability Class. You can check that by Application.internetReachability enum property.

Returns the type of Internet reachability currently possible on the device.

This property is mostly useful on handhelds to distinguish fast and cheap WiFi connection from carrier networking.

Note: Do not use this property to determine the actual connectivity. E.g. the device can be connected to a hot spot, but not have the actual route to the network. Non-handhelds are considered to always be capable of NetworkReachability.ReachableViaLocalAreaNetwork.

http://docs.unity3d.com/ScriptReference/Application-internetReachability.html

Description

Describes network reachability options.

Variables

NotReachable Network is not reachable.

ReachableViaCarrierDataNetwork Network is reachable via carrier data network.

ReachableViaLocalAreaNetwork Network is reachable via WiFi or cable.

Zohaib Javed
  • 323
  • 1
  • 20
0

AFAIK this is not possible with the Unity API.

However the Android SDK provides a ConnectivityManager class which you could call through AndroidJavaObject.Call to retrieve that information on Android devices.

sdabet
  • 18,360
  • 11
  • 89
  • 158