thanks, all. I grabbed Mark's code, and then just had to add <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
to my manifest. works great! On Aug 21, 4:29 am, Mark Murphy <[email protected]> wrote: > Guru wrote: > > /** > > * Checks whether the device is able to connect to the network > > * @param context > > * @return > > */ > > public static boolean isNetworkAvailable(Context context) { > > > ConnectivityManager connectivity = (ConnectivityManager) context > > .getSystemService(Context.CONNECTIVITY_SERVICE); > > if (connectivity == null) { > > Log.w("tag", "couldn't get connectivity manager"); > > > } else { > > NetworkInfo[] info = connectivity.getAllNetworkInfo(); > > > if (info != null) { > > > for (int i = 0; i < info.length; i++) { > > > if (info[i].getState() == NetworkInfo.State.CONNECTED) { > > > return true; > > > } > > > } > > > } > > } > > return false; > > } > > I have been using: > > ConnectivityManager > connMgr=(ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); > NetworkInfo info=connMgr.getActiveNetworkInfo(); > > return(info!=null && info.isConnected()); > > Are there scenarios where a NetworkInfo other than > getActiveNetworkInfo() might be connected? > > -- > Mark Murphy (a Commons > Guy)http://commonsware.com|http://twitter.com/commonsguy > > Android Development Wiki:http://wiki.andmob.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

