Reputation: 6128
i have button in my first activity called Start.
Now when i click on this button it takes 1 to 2 seconds to load the next activity, now at that time the user clicks on the start button multiple times so what happens is that the next activity will open multiple times.
How to overcome this? Is there any way that even if the user clicks on the Start button multiple times open the activity only once.
Upvotes: 0
Views: 485
Reputation: 24012
Don't use anything like a launchMode
or Intent flags
. They are used for different purposes.
Description here
What you have to do is:
Upvotes: 1
Reputation: 8049
Your Options:
ProgressDialog
to the user. Intent
flag FLAG_ACTIVITY_SINGLE_TOP
to ensure only one activity is maintained on the stack. DocumentationlaunchMode=singleInstance
in your AndroidManifest.xml
so only one instance of your Activity
is allowed at a time. DocumentationI would recommend the first, because it can show the user your application is still working even if it takes a few seconds to do the necessary processing to begin your Activity
.
Upvotes: 1
Reputation: 758
You can put the launch mode of your 2nd activity as "Single Instance" in your manifest file.
Upvotes: 1