occasionally useful ruby, ubuntu, etc

6Oct/120

Telling Android to Conserve Data on Mobile Hotspots in Android 4.1

So it turns out there actually is a way to inform your device (as long as it's Android 4.1 or above) which WiFi networks are actually mobile hotspots. It can't (or doesn't, anyway) do this automatically, and having your other devices connect to your mobile hotspot and then download large program updates is no fun! So I discovered the somewhat elusive option in the settings and thought I'd share.

You'd think that to mark a WiFi network as a mobile hotspot you'd check under WiFi settings, right? Turns out this isn't the case; the correct place is actually under Data Usage.


Then, once you click to that page, you see a screen like this:

And that's it! Pretty simple.

If you're a programmer, you can check for this pretty easily (still requires Android 4.1, though). The tricky bit is it's not a mobile hotspot flag you're looking for -- it's whether the connection is metered (limited).

To check this, grab an instance of the ConnectivityManager and simply call isActiveNetworkMetered(), like so:

Context.getSystemService(Context.CONNECTIVITY_SERVICE).isActiveNetworkMetered();

Strictly speaking, to check to see if we're on a mobile hotspot, you'd need to pair it with the check to see if the current connection is WiFi:

Context.getSystemService(Context.CONNECTIVITY_SERVICE).getActiveNetworkInfo().getType() == ConnectivityManager.TYPE_WIFI;

I haven't actually tested this, but I think this should work -- other than the way Context is referred to (which could be replaced with getApplicationContext() or another Context-getter).

Filed under: android Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.