Hello, I am developing an application compose by: 4 activities, one application class (Global) and a remote service with provides the data shown in the active activity (the same data is needed for all activities).
The application class (Global) is where I define and interact with objects that are used by all the activities. Moreover, as it is only instantiated ones at the beginning of the application, I also do things that must be done only once: opening a database at the beginning (the same database is used by both, the remote process and the activities). As the data returned by the remote service must be redirected to the current activity, I bindService() and receive the data from the service in the Global class. I start the service in the onCreate of Global class in order to get the data as soon as possible. I thought that this Global class was only instantiated once during the whole application (at the beginning) but when I bindService(), this class is instantiated again. Therefore, the onCreate is again executed and another process is started. Can someone tell me the correct way no do this? Is It possible to define a common class (with common objects) that is only instantiated once and valid for both, activities and the remote service. Another thing that I would like to know is if is better to use Singleton classes or application classes. Thank you very much. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

