Yes.  I had read that, and I understand that the VM tries to stratify
processes depending on their function and keep my process alive as
long as possible.  What I'm really interested in is detecting when the
the VM (re)-instantiated and garbage collects my Activity class, and
how that relates to the process identifier...

So, with this code, would procewssIDChanged ever be true?  I know it's
a mundane question, but it tells me a lot about Android process
management....



public IfWeirdAlWasAProgrammer extends Activity{

   private static boolean newInstance = true;
   private static int currentProcessId = -1;

   private boolean processIDChanged = false; // non-static on purpose

  @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (newInstance){
            Log.i("WeirdAlWasHere", "Like a surgeon, cuttin' for the
very first tiiiiime.");
            newInstance = false;
            currentProcessId = android.os.Process.myPid();
        }

        if (!newInstance && (currentProcessId !=
android.os.Process.myPid()){
           processIDChanged = true;
           Log.i("WeirdAlWasHere", "I lost on Jeapordy, baby!
Ohhhh!");
        }


    }
}



Thanks again.



On Jul 14, 1:41 pm, Dianne Hackborn <hack...@android.com> wrote:
> Yeah, the process lifetime, which is outlined here:
>
> http://developer.android.com/guide/topics/fundamentals.html#proclife
>
> On Tue, Jul 14, 2009 at 1:38 PM, Richard Schilling <
>
>
>
> richard.rootwirel...@gmail.com> wrote:
>
> > Thanks Dianne.  Very helpful indeed.
>
> > For process lifetime, I don't think you're referring to the "entire
> > lifetime" of an Activity as defined on the API reference page for
> > Activity (http://developer.android.com/reference/android/app/
> > Activity.html<http://developer.android.com/reference/android/app/%0AActivity.html>
> > ):
>
> > "The entire lifetime of an activity happens between the first call to
> > onCreate(Bundle) through to a single final call to onDestroy()".
>
> > Rather, you're referring to a broader lifetime of the process that
> > underlies the Activity.... correct?  This would be the lifetime
> > associated with android.os.Process I assume....
>
> > Richard Schilling
> > Root Wireless
>
> > On Jul 14, 1:23 pm, Dianne Hackborn <hack...@android.com> wrote:
> > > Statics are statics -- they are global to the process.  So their value
> > will
> > > last for the lifetime of the process, which is usually much longer than
> > an
> > > individual activity instance.
>
> > > On Tue, Jul 14, 2009 at 12:52 PM, Richard Schilling <
>
> > > richard.rootwirel...@gmail.com> wrote:
>
> > > > I just ran into a situation where it looks like a static variable
> > > > reference is persisted across activity sessions.  I didn't expect that
> > > > because I thought that when an activity exits, it's de-referenced and
> > > > garbage collected.
>
> > > > I am wondering if anyone can shed some (more) light on when the VM
> > > > eliminates object references for Activities and Services and in
> > > > particular when static variables get reset to default values?
>
> > > > Thanks.
>
> > > > Richard Schilling
> > > > Root Wireless
>
> > > --
> > > Dianne Hackborn
> > > Android framework engineer
> > > hack...@android.com
>
> > > 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
> hack...@android.com
>
> 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 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