Meleagros wrote:Hi all,
i tried to use a class implements the singleton pattern inside an android service. But it didn't get the right instance. Inside activities it works well.
I want to use the service to handle all incomming messages from a jabber server.
If i connect to the jabber server inside a activity i can use the singleton class in all activitys. but not in the service. if i connect inside the service, the activitys dont get the right instance of the singleton.
i tried to implement the serializable interface und put it in a my singleton class in a bundle, an then deliver it to the service. but then i get an error.
another try was to use ja final static HashMap variable. to exchange the class. but that also didn't work.
i am thankful for any ideas to solve this problem...
ps: is use the adapted smack api.
The android.app.Application class
The android.app.Application is a base class for those who need to maintain global application state. It can be accessed via getApplication() from any Activity or Service. It has a couple of life-cycle methods and will be instantiated by Android automatically if your register it in AndroidManifest.xml.
Meleagros wrote:is it the observer pattern? is it the same pattern with the service and the callbacks?
with this i can notify my activities with the connection? so i am not restricted with datatypes?
Users browsing this forum: Google [Bot] and 25 guests