Reputation: 143
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 problem is intent.putExtra() doesnot support sending sockets. So how to do that?
Upvotes: 0
Views: 1501
Reputation: 1006664
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.
Upvotes: 5