How to prevent launching of second copy of application?
I need to guarantee that m开发者_StackOverflow中文版y Android application won't be launched twice. How to do it? I mean in ideal I would need in case of second launch just switch to primary copy.
Consider using android:launchMode
More on that here
According to the Android activity lifecycle, it shouldn't be possible to start a second copy on an activity. If it isn't terminated, it will resume the running instance.
That is the normal behavior of app launching. You don't need to do anything special. (And definitely do not at all use the android:launchMode="singleInstance" option. That is a very special behavior that is probably not what you want.)
精彩评论