I've found a hack: You can kill all APN setting on emulator and You'll not have any data connection before restore them to default ;)
On Oct 13, 1:41 am, "Roman ( T-Mobile USA)" <roman.baumgaert...@t- mobile.com> wrote: > On the emulator you always have data connectivity. For example with > enabling the Airplane mode you can still browse the web (which should > not be the case). > > I submitted a bug on this (don't remember the bug number). > > -- > Roman Baumgaertner > Sr. SW Engineer-OSDC > ·T· · ·Mobile· stick together > The views, opinions and statements in this email are those of the > author solely in their individual capacity, and do not necessarily > represent those of T-Mobile USA, Inc. > > On Oct 12, 3:29 pm, stanlick <stanl...@gmail.com> wrote: > > > This code seems to return true unconditionally. Of course, I suppose > > it could be the emulator, but here is the deal. When I switch my wi- > > fi off and try using the emulator browser, I get the built-in Android > > 404 page. However, when my application tests for a net connection > > using the code below, it returns true. > > > public boolean iCanHasDataNowKThxBye() { > > ConnectivityManager connMgr=(ConnectivityManager) > > getSystemService(Context.CONNECTIVITY_SERVICE); > > NetworkInfo info=connMgr.getActiveNetworkInfo(); > > > return(info!=null && info.isConnected()); > > > } > > > Scott > > > On Aug 21, 6:29 am, Mark Murphy <mmur...@commonsware.com> 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 android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---