delight-im / Android-DDP

[UNMAINTAINED] Meteor's Distributed Data Protocol (DDP) for clients on Android
Apache License 2.0
274 stars 54 forks source link

Use Android-DDP on different activities #17

Closed adam-jack-2 closed 9 years ago

adam-jack-2 commented 9 years ago

All Android-DDP examples shows on one activity. How can i use it on different activities. For example i connect my server in first activity and go next activity. How can i carry it. Maybe i can use singleton but i don't know.

How can i implement it?

Thank you.

ocram commented 9 years ago
  1. Singleton pattern: http://www.vogella.com/tutorials/DesignPatternSingleton/article.html#singleton_code
  2. Custom Application subclass: http://www.intridea.com/blog/2011/5/24/how-to-use-application-object-of-android
  3. A Service running in the background: http://developer.android.com/guide/components/services.html

Whatever solution you choose, you will communicate with Meteor from that new class and thus you have to communicate between that class and your Activity instances as well.

This is why, in the examples, there's only the code with a single Activity -- that model is much simpler to understand (and use).

For information regarding the use of those three patterns, please search on the web as there's a lot of documentation.

Does that help?