diff options
| author | Jeff Sharkey <jsharkey@android.com> | 2012-04-12 18:34:54 -0700 |
|---|---|---|
| committer | Jeff Sharkey <jsharkey@android.com> | 2012-04-16 11:20:27 -0700 |
| commit | 9f7cbf0e50bcb7e9163b23524814003ba8784732 (patch) | |
| tree | d9647d60bbe2f5f00142c72b6aef841f8dad4718 /core/java/android/net/ConnectivityManager.java | |
| parent | a94afeb5b3c3c95c6d2cf0cd4d69587aba569cfb (diff) | |
API to report if active network is metered.
Report to developers if active network is "metered" and define it
as the user being sensitive to heavy data usage.
Bug: 3001465
Change-Id: I855ca3cd3eb1de3c4814148d70ccf24957af898a
Diffstat (limited to 'core/java/android/net/ConnectivityManager.java')
| -rw-r--r-- | core/java/android/net/ConnectivityManager.java | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java index de169858be37..ef4209f8495e 100644 --- a/core/java/android/net/ConnectivityManager.java +++ b/core/java/android/net/ConnectivityManager.java @@ -373,10 +373,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. - */ + * Returns details about the currently active data network. When connected, + * this network is the default route for outgoing connections. You should + * always check {@link NetworkInfo#isConnected()} before initiating network + * traffic. This may return {@code null} when no networks are available. + */ public NetworkInfo getActiveNetworkInfo() { try { return mService.getActiveNetworkInfo(); @@ -856,4 +857,19 @@ public class ConnectivityManager { } catch (RemoteException e) {} return false; } + + /** + * Returns if the currently active data network is metered. A network is + * classified as metered when the user is sensitive to heavy data usage on + * that connection. You should check this before doing large data transfers, + * and warn the user or delay the operation until another network is + * available. + */ + public boolean isActiveNetworkMetered() { + try { + return mService.isActiveNetworkMetered(); + } catch (RemoteException e) { + return false; + } + } } |
