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.
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.
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).
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.
Use android:launchMode="singleTask"
or android:launchMode="singleInstance"
in your manifest.xml in your activity
tag
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With