No, I don't have code lying around for that. What you would do is create a callback for the ConnectivityManager that would send a message to your UI thread (or perhaps fire an intent at it?) to tell it to change the value of the TextView. You can read up on Messengers, but the point is that you will have some non UI thread (at least, iirc, I suppose it is possible that this callback runs in the UI thread, in which case you're in luck, but I can't remember) that will need to tell the UI thread to change the value of the textview.. You can find examples of using ConnectivityManager on google (I found them :-), and you can read about Messenger and the related in the documentation..
Kris On Mon, Oct 24, 2011 at 8:13 AM, sourabh sahu <souruit...@gmail.com> wrote: > Can you please provide me little bit of Code for that. > > Thanks, > Souerabh > > On Mon, Oct 24, 2011 at 5:14 PM, Kristopher Micinski > <krismicin...@gmail.com> wrote: >> >> I don't think you thought about how to implement this using the way I >> described. >> >> Instead of having a thread sitting in the background, why not register >> a callback with the system that, whenever the connectivity changes, >> performs an appropriate action? For example, whenever the >> connectivity changes, it will call your handler and you can change the >> text in the textview. >> >> A thread just sounds like a nasty way to implement this since there is >> already a way to do this.. However if you really want to look at >> ConnectivityManager more, it has an isConnectedOrConnecting() method.. >> >> Kris >> >> On Mon, Oct 24, 2011 at 3:08 AM, sourabh sahu <souruit...@gmail.com> >> wrote: >> > Thanks, but this thing I figured.main issue is ,there is a need of >> > Thread >> > kind of stuff which loops around whenever network comes online or >> > offline. >> > It should automatically reflect it to view. >> > >> > On Mon, Oct 24, 2011 at 11:47 AM, Kristopher Micinski >> > <krismicin...@gmail.com> wrote: >> >> >> >> Sounds like the first thing you need to be able to do is to be able to >> >> detect when the network comes online and offline right? >> >> >> >> >> >> http://developer.android.com/reference/android/net/ConnectivityManager.html >> >> >> >> On Mon, Oct 24, 2011 at 2:01 AM, sourabh sahu <souruit...@gmail.com> >> >> wrote: >> >> > I have a TextView, what I want is whenever my Network comes >> >> > online/offline.It should get reflected to TextView. >> >> > How Can I do this. >> >> > >> >> > Please suggest. >> >> > Thanks, >> >> > Sourabh >> >> > >> >> > -- >> >> > 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 >> >> >> >> -- >> >> 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 >> > >> > -- >> > 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 >> >> -- >> 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 > > -- > 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 -- 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