mailsuren14 / queueman

Automatically exported from code.google.com/p/queueman
0 stars 0 forks source link

Replace internet / connectivity check #22

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Current check is expensive. Use Android network object instead

From Mark Murphy;

ConnectivityManager is where most of this resides, though it is
incompletely documented.

Specifically, getActiveNetworkInfo() will give you a NetworkInfo object
that can tell you what sort of network it is (CDN or WiFi). My
assumption, as yet untested, is that getActiveNetworkInfo() will return
null if there is no active network (i.e., no connectivity whatsoever). 

Original issue reported on code.google.com by OlliTech on 17 Dec 2009 at 8:01

GoogleCodeExporter commented 9 years ago

Original comment by OlliTech on 17 Dec 2009 at 8:01

GoogleCodeExporter commented 9 years ago

  ConnectivityManager connectivityManager = 
(ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
connectivityManager.getNetworkInfo(0).isConnectedOrConnecting()

 add the following permission in the manifest:
Code:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Props -> http://www.anddev.org/viewtopic.php?p=19332

Original comment by OlliTech on 17 Dec 2009 at 8:06

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r86.

Now uses cocnnectivity mamager, but requires extra permission.
requestRouteToHost may be of use, but is minimally documented and requires an 
ip address.

Original comment by OlliTech on 4 Jan 2010 at 7:50