Use a service: http://developer.android.com/reference/android/app/Service.htm
On Mon, Jun 21, 2010 at 12:05 AM, qwesthead <[email protected]> wrote: > I would like to know what is the recommendation for socket connection > management in Android? > > In our App we would like to be connected to a TCP/IP server when our > app is in the foreground or paused. So, create a connection to a TCP/ > IP server when the App starts --basically, On Create of the launcher > activity. However, we do not want to create a new connection and close > connection every time an activity is created, paused, destroyed or > orientation changed. So, we save the connection object in the App > class and the activities will reuse the same connection. Question is > when do I close it? I would like to close the socket when the App is > "paused", "stopped" or "destroyed". The problem is these messages are > not sent in the App context. How can I figure out if the App is in > foreground or not? Even the "Terminated" event for an App is not > guaranteed to be delivered. So, in that case how do I know when to > disconnect? > > is there any recommendation on how to manage socket connection in > Android? it is very weird that Android does not allow apps to 'exit" > or be notified when the app exits. > > -- > 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 -- http://diastrofunk.com, http://developingthedream.blogspot.com/, http://www.youtube.com/user/revoltingx, ~Isaiah 55:8-9 -- 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

