Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable only one instance of my application

I need only one instance of my app in android. If I run my app after installation and go to Home screen, and again run my app (click on app's icon), second instance is opened, I need to open already running first instance not to run second instance. I don't know how to solve this.

like image 854
Palejandro Avatar asked Feb 27 '12 15:02

Palejandro


People also ask

What is a single instance application?

A Single Instance application is an application that limits the program to run only one instance at a time. This means that you cannot open the same program twice.

How to run only one instance of an application in c#?

One of the most common reasons to limit the number of instances is to restrict the access to some sensitive resources. For this purpose, we use the Mutex object. This approach can be used on all three types of desktop applications (console, winforms, WPF).

How do I restrict a class to create one instance in C#?

Using singleton, that is a class which only allows a single instance of itself to be created. The operation of this pattern is simple and could be reduced to the following: Hide the constructor of the Singleton class, so that clients may not be instantiated.


1 Answers

Use android:launchMode="singleTask" or android:launchMode="singleInstance" in your manifest.xml in your activity tag

like image 114
Vyacheslav Shylkin Avatar answered Oct 29 '22 01:10

Vyacheslav Shylkin