Discussion:
Translucent Activity not calling onStop() on exit
Craig Russell
2009-12-03 15:18:43 UTC
Permalink
I'm having this strange issue where upon exiting a subactivity that is
translucent (android:theme="@android:style/Theme.Translucent" ) the
onStop() method doesn't appear to be called.

I have a TimerTask that runs and is supposed to be terminated when the
subactivity ends in the onStop() method, but I'm instead left with an
orphaned thread running in the background. It go particularly bad
when I ran the subactivity several times. When I revert to no theme,
the onStop() method is called and the activity behaves properly.

Is there something I missed about how Translucent activities'
lifecycles differ from standard activities?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
Craig Russell
2009-12-03 15:22:25 UTC
Permalink
I suppose by putting it into onPause(), it might work, but why does it
behave differently?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
Craig Russell
2009-12-03 15:34:26 UTC
Permalink
Well, that worked but I don't entirely understand why. So that
activity is being paused when I exit it, but it's still on the
activity stack?
Post by Craig Russell
I suppose by putting it into onPause(), it might work, but why does it
behave differently?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
Kirrrilka
2009-12-03 20:16:01 UTC
Permalink
If you take a look at activity lifecycle chart you will see that
onStop is called only if activity become invisible
But as you said you have translucent activity on top: that's why only
onPause is called!

RTFM http://developer.android.com/intl/zh-CN/reference/android/app/Activity.html#ActivityLifecycle

Happy coding!!!
Post by Craig Russell
Well, that worked but I don't entirely understand why. So that
activity is being paused when I exit it, but it's still on the
activity stack?
Post by Craig Russell
I suppose by putting it into onPause(), it might work, but why does it
behave differently?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
Loading...