They are NOT two different situations. That's the source of your
confusion.

They are both a different app being in front of your activity. You
mention the call screen and the launcher, but others are possible as
well.

Once your activity is no longer visible, onStop() is called. If it
later becomes visible, and the instance hasn't been destroyed, then
onRestart() will be called. This sequence occurs regardless of just
which activity came to the front - and you're not allowed to know
about activities of other applications for security reasons.

The launcher is just pretty much just another application. The home
button just sends the intent that launches it. You can supply a
different application for that intent, just like you can supply a
different application for any intent. (Not that it's always a good
idea).

So you don't know -- and I can't see why you'd care -- whether it was
the Launcher that came in front and triggered onStop().

But what you COULD do is write your own launcher, if you really wanted
to know if the home key was pressed for some reason. I'm not sure you
could find out about it until later, though. Maybe. But what would you
do with that information? You're being stopped, after all. You don't
get to run any UI or anything.

On Aug 8, 8:59 pm, optimusgeek <[email protected]> wrote:
> I mean I want to do something when my app going to be stopped.(not
> destroyed)
> and the situations are two cases as I mentioned.
> #1 pressing home key
> #2 another app comes to front like an incoming call.
> both cases have same process onPause() -> onStop()
> so I cannot put some codes in onPause or onStop method.
> because I want to put different codes by the situation(#1 or #2)
>
> On 8월9일, 오후12시09분, TreKing <[email protected]> wrote:
>
>
>
> > On Sun, Aug 8, 2010 at 9:49 PM, optimusgeek <[email protected]> wrote:
> > > Is there any way to find out?
>
> > What difference does it make how your app is stopped?
>
> > --------------------------------------------------------------------------- 
> > -----------------------
> > TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> > transit tracking app for Android-powered devices

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