I have three questions:-
1) I am creating an OPCUA client for an OPCUA server. My Application has several avtivities, and most of them need the connected client. What is the best way to make my connected client available in all my actvities. I have currently used a static variable to hold my client. But is there any other better way. My client is not Serializable or Parcelable and thus cannot be passed as an intent argument.
2) Can I maintain this static variable in a Service and access the same in all my activities with MySerivce.connectedClient? Would that be good programming practice?
3) What if my application force closes and the connection with my server is not released. I want to be able to disconnect from my server even if my application force closes. Is there a way to ensure this (except for enclosing all my code in a try catch block) ?
Please suggest.