A better approach to solve this issue would be to use a global state. I.e.: connect to the server once and use the same connection in both activities. This can be done using the Application
class. Refer to this Link for more details and examples.
But basically what is going to happen is that you have the connection objects inside of the globalState
(Can be any name), and you will access it from ActivityA
and ActivityB
. Thus you wouldn't have to connect to the server again.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…