On Sun, Jun 26, 2011 at 7:06 AM, Neilz <[email protected]> wrote:
> I assume there is a way of finding out how your Activity was started,
> for example:
>
> Intent i = new Intent(ActivtyA.this, ActivityB.class);
>
> ...when B starts, I want to find out the activity that started it,
> which in this case would be an instance of ActivityA. How can I get
> this information?

AFAIK, you can't.

> Following on from that, is there a way to tell:
>
> a) That the application has just been launched from the main
> application launcher, from the home screen.

You can see if the Intent has CATEGORY_HOME. This isn't a guarantee
(non-home-screen "launchers" might set this), but it's a reasonable
test.

> b) If the application has just been resumed via the recent apps list,
> i.e. hold down home button, select app from recent list.

You can see if the Intent has FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY.
This too isn't a guarantee (other things might set this flag for crazy
reasons), but it's a reasonable test.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android 3.1 Programming Books: http://commonsware.com/books

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