Thanks, Miguel Morales. When network disconnected, the code will check right now. Yes, now start the timer to connect periodically till it connect successfully. It works. After googling, Android has one manager, ConnectivityManager, can detect the network information. So can check the available network and reconnect it as soon as possible. If Anybody who used it, can give me some more advise, I would appreciate very much.
On Tue, Nov 16, 2010 at 10:01 AM, Miguel Morales <[email protected]>wrote: > Something like this wouldn't be hard to implement in your application. > Android offers several classes that will help you in probing for the > state of the network connection, wifi connection, etc. > > If what you're doing is just regular socket TCP communication simply > wrap your communication in an try/catch block and handle your > reconnect logic there. (For example, setup a timer that'll check if > the connection has returned.) > > I'm not aware of any broadcast messages that are sent when the network > connection changes, but I haven't looked. That would be a good way of > handling it as well. > > On Mon, Nov 15, 2010 at 5:56 PM, Jenus Dong <[email protected]> wrote: > > Hi, all > > Such like messager app, client/server framework, using tcp long > connection > > using heart beating packet. > > Cause TCP connection, so when local network is diable or changed, > > connection would be disconnected. But to the client, it may not be known > > right now till > > the next interaction with the SERVER. > > Is there a general solution to reconnect automatically when network is > > available again? > > For example, a broadcast receiver would be triggerd when network > connection > > changed, and reconnect when available? > > > > Further more, how to check the network capacility, auto-connect the > wanted > > one cause good bandwith? > > > > Regards > > > > -- > > 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]<android-developers%[email protected]> > > For more options, visit this group at > > http://groups.google.com/group/android-developers?hl=en > > > > -- > ~ Jeremiah:9:23-24 > Android 2D MMORPG: http://developingthedream.blogspot.com/, > http://www.youtube.com/user/revoltingx > > -- > 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]<android-developers%[email protected]> > 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 [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

