I am creating a UDP messaging system for Android application. For that I have created a seperate class with sending, receiving, parsing threads. The class has to be instanciated only one - ie. only one UDP server!
Now, in Android you have multiple activities in your design which are basically different classes. I would like to use my UDP communication iterface from those different classes. But currently UDP CI is instanciated once in the main class. Therefor I cannot access the object from different classes. Moreover, the CI parse module will have to change settings/UI/... of the whole app depending on the message.
Therefore:
- Do I need to have instantiation at all if I do not need more than 1 object?
- Is it a good choice to have everything in the class static?
- At some point I will need to talk the other way round (obj->main). Should I use callbacks or just pass necessary resources from main to the CI and do things with them in CI?
I hope I described the problem clear enough. Please ask me if any questions arise.