Barmaley
Barmaley

Reputation: 16363

How to prevent launching of second copy of application?

I need to guarantee that my 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.

Upvotes: 1

Views: 460

Answers (3)

hackbod
hackbod

Reputation: 91321

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

Upvotes: 1

Asahi
Asahi

Reputation: 13506

Consider using android:launchMode More on that here

Upvotes: 2

Jess
Jess

Reputation: 42928

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.

Upvotes: 1

Related Questions