1

The main/launcher activity in my app is a login page (Activity A). Once the user is authenticated, they are taken to the main area of the application, e.g. Activity B. So now the current activity stack of this task is A > B.

I then press the home button on the phone and am taken to the Android home screen. I re-launch my app via short cut key in HTC Desire Z(See Image after Space there are two Short Cuts 1 and 2), and I am taken to Activity A, instead of Activity B. Either the activity stack is now A > B > A, or there are now two separate tasks with activity stacks A > B, and A respectively. What I want is to be taken back to Activity B when I relaunch the app..enter image description here

I followed this link
The above solution worked for 2.3.3 but in ICS 4.0.3 it has an issue that i am not taken to Activity B.
How do i resolve this,In ICS I am not able to see the what Intent flag system is using to launch activity when short Cut is Pressed,is this a System BUG?
Please Help
NITZ

Community
  • 1
  • 1
NitZRobotKoder
  • 1,046
  • 8
  • 44
  • 74

1 Answers1

0

The pattern that I tend to use for the login like this. I'll use A to mean Login and B to mean Main application.

I make B the launcher Activity, and in its onCreate() I check if a login is needed and if so, then I immediately launch Activity A. Once A is done, i finish() it, so that I'm back to B.

This way my activity stack stack never contains the Login activity, except when it's being used. ie, after a Login is done, then only B is on the stack.

stuckless
  • 6,515
  • 2
  • 19
  • 27
  • good approach, But my project need many changes now if i need to follow yours..Any idea why system is behaving So.. – NitZRobotKoder Jun 27 '12 at 10:41
  • Have you tried setting, `android:clearTaskOnLaunch=true` and `android:launchMode=singleInstance` in your manifest entry for the login activity? – stuckless Jun 27 '12 at 12:21
  • 1
    I Need my Activity A to be Alive Till my App is Shut..So i cant Use android:clearTaskOnLaunch=true!!!! – NitZRobotKoder Jun 27 '12 at 12:41
  • I'm not sure I understand "alive" comment for the Login activity. Once Activity B is started, Activity A is paused. It's not it's going to have tasks still running Activity A... and if it does, then they should probably be in `Service` or `Application`. I would think the purpsoe of a Login activity would be to log the user in and if sucessuful move to the "main" activity, at which point the Login activity is no longer required. – stuckless Jun 27 '12 at 13:22