[android-developers] Re: Main Activity Launches On Stack Every Time Home Screen Icon Is Clicked

2011-04-11 Thread String
A couple of things to keep in mind:

First, launcher icons are simply shortcuts to intents, and these intents 
point to specific activities, not to your app as a whole. In the case of 
your main launcher icon, the one in the app drawer, the target activity is 
the one in your manifest with this intent filter:

intent-filter
action android:name=android.intent.action.MAIN /
category android:name=android.intent.category.LAUNCHER /
/intent-filter

In your case, I'm guessing that's the LoginActivity. What you probably need 
to do is insert a check in its onCreate() method to reopen the 
BrowseActivity if the user's already logged in. Something like:

if (loggedIn) {
startActivity(new Intent(this, BrowseActivity.class));
finish();
}

It may seem like a huge hack, but it's not really, not in the context of 
launcher intent shortcuts.

Second, keep in mind that the activity *stack* is exactly that - a stack of 
the recently-opened activities in your app. By default, opening an activity 
simply adds it to that stack, on top of whatever was already there. If you 
want different behavior, look at the stack-control intent flags (
http://developer.android.com/guide/topics/fundamentals/tasks-and-back-stack.html
).

String

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

[android-developers] Re: Main Activity Launches On Stack Every Time Home Screen Icon Is Clicked

2011-04-11 Thread kaciula
Check out my answer (kaciula user) on this issue on stackoverflow.com:

http://stackoverflow.com/questions/3042420/home-key-press-behaviour/4782423#4782423

I've filed a bug on b.android.com a couple of months ago but the bug
report is still unnoticed.

On Apr 9, 9:14 am, Tony Chuinard tony.chuin...@gmail.com wrote:
 My application consists of a LoginActivity followed by a
 BrowseActivity.  When the user hits the Browse Activity, then hits the
 Home button, then hits the application icon again, the LoginActivity
 relaunches (but they're already logged in and in the browse activity
 so they should be there).

 However, if I hit back, the BrowseActivity is still there, and the
 LoginActivity is revisible when I hit back twice.  It seems like the
 LoginActivity gets pushed to the top of the stack and displayed every
 time the application is launched, but the docs say that the last
 activity from that 'task' will be launched (which is what I want - a
 return to the BrowseActivity).

 I have a static LoginManager class, so I could check if that data is
 null or not in LoginActivity onCreate() and do a finish() if
 necessary, but I feel like that's a huge hack when my application
 should be behaving like this already.

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