Monday, July 11, 2011

[android-developers] Re: Android partially destroying an app?

> The docs says this:
> http://developer.android.com/guide/topics/fundamentals/activities.htm...

Yes. But it doesn't say exactly when this would happen and it doesn't
say whether a single Activity could be destroyed or only as part of
the whole app being destroyed (or when this would happen).

> Not sure what you mean by "developer thinks"

I mean when the developer gets an error report and a stack trace in
the developer console that indicates that ActivityB is started but
ActivityA is not. The typical (error) situation for this is when
ActivityA initializes some static data that is accessed by ActivityB.

On 10 Juli, 17:47, Kostya Vasilyev <kmans...@gmail.com> wrote:
> The docs says this:
>
> http://developer.android.com/guide/topics/fundamentals/activities.htm...
>
>  >>
> If an activity is paused or stopped, the system can drop it from memory
> either by asking it to finish (calling its |finish()| method), or simply
> killing its process.
> <<
>
> IIRC, the emulator has a setting / button somewhere to trigger the
> destruction of unused activities without killing the process, so there
> is a way to test this case.
>
> More below:
>
> 10.07.2011 19:17, nadam ?????:
>
> > In a low memory situation Android can shut down apps and has some
> > logic to prioritize which apps to shut down first. I have read some
> > comments that Android can also partially destroy an app by destroying
> > Activities that are not currently used. Since I haven't found any
> > documentation about this, I suspect that this could be a
> > misunderstanding and that what they are experiencing is in fact that
> > the whole app has been destroyed and then the app has been started
> > again by the user.
>
> > Example:
> > 1. The app starts and creates ActivityA
> > 2. ActivityA starts ActivityB
> > 3. ActivityB starts another app, for instance Google Maps
> > 4. Android destroys only ActivityA due to low memory
>
> In this case, the entire application goes into background state (unless
> there is a foreground service, etc.), so I'd be surprised if this
> actually happens, or should be expected.
>
> > But what actually happened:
> > 4. Android destroys the whole app due to low memory
> > 5. The user presses the back-button
> > 6. The app starts again and creates ActivityB
> > 7. Developer thinks (based on stack-traces) that the app has been
> > running all the time but only ActivityA was destroyed
>
> Not sure what you mean by "developer thinks" - if the entire process was
> destroyed, then the new process id will be different. You can easily see
> this in the logcat or other tools (DDMS, ps, top).
>
> > If Android can in fact destroy just a single Activity, how is the
> > decision made between destroying unused Activities in the least 5
> > prioritized apps vs. completely destroying the least 2 prioritized
> > apps?
>
> > Or is the partial destroying just a myth (like the destroying statics
> > myth)?
>
> --
> Kostya Vasilyev

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment