Reputation: 11
While application will be started, I want to launch one activity if some condition is satisfied else want to launch another activity. How to do this?
Upvotes: 1
Views: 294
Reputation: 5076
I don't know much about your particular use case, but if your application has to launch different activities depending on the task it is supposed to do, you should consider having appropriate intent-filters for each, and sending an Intent that's in accordance to the intended effect. That will make the correct activity be launched depending on the Intent, which is one of the great features of Android.
But of course, if you can only decide which activity is best once you launch your app, this approach doesn't work, and you have to launch an initial activity to decide which one to call next.
If it's highly likely that one activity will be launched, you might consider launching it as the first activity and then testing whether you need to launch another instead. That's probably cleaner than having a separate activity just to make the decision about which other activity to launch.
Bruno Oliveira, Developer Programs Engineer, Google
Upvotes: 0
Reputation: 7475
you must do it handling all conditions in an initial activity, which will check your rules and start the other activitys.
Upvotes: 2
Reputation: 43098
Start the one, and in onCreate()
check the condition. If it is not satisfied start your another activity.
Upvotes: 3