From f58b7d82d0a496a146f241c1f8e69c7c3a3d6c5f Mon Sep 17 00:00:00 2001 From: Scott Main Date: Thu, 6 Oct 2011 19:02:28 -0700 Subject: [PATCH] docs: some helpful javadocs for network info Change-Id: I8f1879bf10acd6371a76f11a8e5ec08643c3f943 --- core/java/android/net/ConnectivityManager.java | 5 +++++ core/java/android/net/NetworkInfo.java | 17 +++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java index 0052dd0b62..a569317e25 100644 --- a/core/java/android/net/ConnectivityManager.java +++ b/core/java/android/net/ConnectivityManager.java @@ -360,6 +360,11 @@ public class ConnectivityManager { } } + /** + * Gets you info about the current data network. + * Call {@link NetworkInfo#isConnected()} on the returned {@link NetworkInfo} + * to check if the device has a data connection. + */ public NetworkInfo getActiveNetworkInfo() { try { return mService.getActiveNetworkInfo(); diff --git a/core/java/android/net/NetworkInfo.java b/core/java/android/net/NetworkInfo.java index 537750a79a..7286f0dc60 100644 --- a/core/java/android/net/NetworkInfo.java +++ b/core/java/android/net/NetworkInfo.java @@ -22,8 +22,9 @@ import android.os.Parcel; import java.util.EnumMap; /** - * Describes the status of a network interface of a given type - * (currently either Mobile or Wifi). + * Describes the status of a network interface. + *

Use {@link ConnectivityManager#getActiveNetworkInfo()} to get an instance that represents + * the current network connection. */ public class NetworkInfo implements Parcelable { @@ -38,7 +39,7 @@ public class NetworkInfo implements Parcelable { * SCANNINGCONNECTING * CONNECTINGCONNECTING * AUTHENTICATINGCONNECTING - * CONNECTEDCONNECTED + * CONNECTEDCONNECTED * DISCONNECTINGDISCONNECTING * DISCONNECTEDDISCONNECTED * UNAVAILABLEDISCONNECTED @@ -159,9 +160,12 @@ public class NetworkInfo implements Parcelable { } /** - * Reports the type of network (currently mobile or Wi-Fi) to which the - * info in this object pertains. - * @return the network type + * Reports the type of network to which the + * info in this {@code NetworkInfo} pertains. + * @return one of {@link ConnectivityManager#TYPE_MOBILE}, {@link + * ConnectivityManager#TYPE_WIFI}, {@link ConnectivityManager#TYPE_WIMAX}, {@link + * ConnectivityManager#TYPE_ETHERNET}, {@link ConnectivityManager#TYPE_BLUETOOTH}, or other + * types defined by {@link ConnectivityManager} */ public int getType() { synchronized (this) { @@ -226,6 +230,7 @@ public class NetworkInfo implements Parcelable { /** * Indicates whether network connectivity exists and it is possible to establish * connections and pass data. + *

Always call this before attempting to perform data transactions. * @return {@code true} if network connectivity exists, {@code false} otherwise. */ public boolean isConnected() {