How To Send Tcp Sockets From One Activity To Another In Android?
Assume that i have created a client TCP Socket in Activity A. I want to send that Socket to Activity B. Now in Activity B, based on some conditions i will close that socket. The pr
Solution 1:
If you think that there are multiple activities that "own" a socket, then none of them should "own" the socket. Something else, like a Service
, should be in charge of managing the socket. In this case, Activity A could start a Service
to do the socket work, and Activity B can stop the service when the socket is no longer needed.
Otherwise, if those activities are that tightly coupled, they should not be separate activities. Activities are designed to be loosely coupled, akin to Web pages in a Web app.
Post a Comment for "How To Send Tcp Sockets From One Activity To Another In Android?"