You could retrieve the ActivityInfo for the current activity from the
package manager, and that will have the process it is running in.  But this
really seems like a hack.  Why not have a single Application object, that
allows others to register to receive the callbacks they are interested in?

(And honestly, you don't need the Application object.  Stuff you do in
onCreate() you can do the first time someone accesses whatever global object
they want...  which can actually be better, to avoid initializing things
that you don't need.  And there is also a broadcast that gets sent when
onLowMemory is called, so you can just register for that.)

On Tue, Jul 14, 2009 at 11:35 AM, magicpig <[email protected]> wrote:

> On Tue, Jul 14, 2009 at 12:12 AM, magicpig <[email protected]>
> wrote:
>
>    Thanks Dianne for the quick reply.
>
>    My two Application.java do some more things than having the
> statics:
>     1. own the ability to store current activity for use in all the
>     activities in the same process. (In the former description, I just
>    talked about two for simple).
>    2. Creating some instances for later use(maybe can be moved to
>    statics)
>
>     So, if there is a way for replacing this easily, I am happy to do.
>
>    BTW, I think we can read the process name, right?
>
>    Thanks a again.
>
>
>
> On Jul 15, 1:58 am, magicpig <[email protected]> wrote:
> > Thanks for the reply.
> >
> > I am trying hard to merge them together and the Application logic
> > seems a little more than setting the globals, such performing
> > differently on onLowMemory,  onTerminate and  onConfigurationChanged.
> >
> > So,is it possible to get the intent that starts the activity or the
> > different process name in Application#onCreate?
> >
> > Thanks
> >
> > On Jul 14, 2:20 pm, Dianne Hackborn <[email protected]> wrote:
> >
> > > Sorry, you can't do that.  There are really very few reasons to have a
> > > custom Application anyway.  I would generally suggest staying away from
> it,
> > > and just using statics for your globals.
> >
> > > On Mon, Jul 13, 2009 at 11:17 PM, magicpig <[email protected]>
> wrote:
> > > > HI,
> >
> > > >      I need  two activities run in different processes in the same
> > > > application. Now I have made it work by specifying the different
> > > > process name in "android:process".
> >
> > > >        But I met a problem,  from
> >
> > > >
> http://developer.android.com/guide/topics/manifest/application-elemen...
> > > > ,
> > > > we have only one superclass of Application will run before the
> > > > activity starts(I have tested it, and each time a after new processes
> > > > start, this Application(its superclass) will run before activity).
> > > > But, my two activities have two different superclasses of
> > > > Applications. So, how to make Applications for different activities
> > > > run for its corresponding activity?
> >
> > > >       If there is no way to use different Application class for
> > > > different activity, how can I make a flag for the common Application
> > > > superclass to judge which process(by getting its name) is running?
> >
> > > >      BTW, the two activities were on the separated development flow
> > > > and I am trying to merge them.
> >
> > > > Thanks a lot.
> >
> > > --
> > > Dianne Hackborn
> > > Android framework engineer
> > > [email protected]
> >
> > > Note: please don't send private questions to me, as I don't have time
> to
> > > provide private support, and so won't reply to such e-mails.  All such
> > > questions should be posted on public forums, where I and others can see
> and
> > > answer them.
> >
> >
>



-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to