Thank you so much, Mark.

I am using a bound service in a remote process and I have already
solve the comunication between 2 processes (the application shown and
the service).

I think that my service must be implemented in a separate process
because it implements a CPU intensive work and it used to block the
GUI when I used AsyncTask to refresh the GUI, maybe there is other
alternatives.
Any sugerences?

The good point of the Application class is that it is instanciated and
onCreated before any other component of the application.

thank you very much again.



On 28 sep, 16:23, Mark Murphy <mmur...@commonsware.com> wrote:
> On Wed, Sep 28, 2011 at 10:17 AM, <Hera> <aide...@gmail.com> wrote:
> > 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).
>
> You do not need a remote service.
>
> > 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).
>
> You do not need a remote process.
>
> > 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.
>
> That is because you are using a remote process when you do not need
> one. Get rid of the remote process, and your problem will be solved.
>
> > 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.
>
> Make it a local service.
>
> > Another thing that I would like to know is if is better to use
> > Singleton classes or application classes.
>
> A custom Application class does not necessarily give you anything over
> a singleton. The downside of an Application class is that there can
> only be one. In particular, I'd never create a library that depended
> upon a custom Application class, as that library would not be able to
> work in tandem with other such libraries.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> Android App Developer Books:http://commonsware.com/books

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to