I wanted to ask a practical question about checking for network connection, 
which is probably a simple question. I am sure this is an easy question. 

I'm looking at this: 

http://developer.android.com/training/basics/network-ops/connecting.html

"Before your app attempts to connect to the network, it should check to see 
whether a network connection is available using 
getActiveNetworkInfo()<http://developer.android.com/reference/android/net/ConnectivityManager.html#getActiveNetworkInfo%28%29>
 and 
isConnected()<http://developer.android.com/reference/android/net/NetworkInfo.html#isConnected%28%29>
."

This is in context of doing 10s of networks calls on multiple threads to 
retrieve small files (about 20K) over http. 

In practice, is there any cost for making this call? Does it initiate a 
network operation or stay on the device? What percentage of the time is it 
actually wrong? Would it be actually faster to see if one of my http 
operations gets a sockettimeoutexception or a connectiontimeoutexception?

Based on that webpage, it calls isConnected() on a UI thread, just before 
explaining that "network operations can involve unpredictable delays" and 
should be done. Does that mean that isConnected() is a short and 
predictable delay, or should I not read that much into it? 

In one of the battery life classes at I/O, they talked about how the 3G 
radio takes a bit to warm up, and that you might as well do a bunch of 
network traffic while it is warm (paraphrasing a bit). Does simply calling 
isConnected() warm up that radio? 

Nathan

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to