Android Question Prevent running more than one instance of the same APP

Pedro Caldeira

Active Member
Licensed User
Longtime User
Hello guys,
I need to prevent my app to run more than one time.
Is there a way to check if the App is running and prevent from being launched again, by clicking its icon ?

Thanks
 

Pendrush

Well-Known Member
Licensed User
Longtime User
I don't think it is possible to run more then one instance of any app.
There is option on some devices as Xiaomi "second space" that allow two different installation of same app on same device, but you cannot see "other" space from your app, so you cannot prevent two different installation.
 
Upvote 0

artsoft

Active Member
Licensed User
Longtime User
I don't think it is possible to run more then one instance of any app.
There is option on some devices as Xiaomi "second space" that allow two different installation of same app on same device, but you cannot see "other" space from your app, so you cannot prevent two different installation.

I know this is an old thread - but please allow my to answer here!

@Pendrush This is not correct completely!

When I start my app with a foreground service (together with a notification icon and message in the message bar), I can go back to my app by clicking the notification.

But when I remove my app from task list and click to the normal app icon which is located on my home screen, I can start a second instance of my app.

And I guess this is exactly what @Pedro Caldeira means.

I also have a XIAOMI Redmi Note 10Pro smartphone. And this fact (the starting of a second instance of my app) is really stupid in the OS!

best regards
ARTsoft
 
Upvote 0

emexes

Expert
Licensed User
Last edited:
Upvote 0

edgar_ortiz

Active Member
Licensed User
Longtime User
I know this is an old thread - but please allow my to answer here!

@Pendrush This is not correct completely!

When I start my app with a foreground service (together with a notification icon and message in the message bar), I can go back to my app by clicking the notification.

But when I remove my app from task list and click to the normal app icon which is located on my home screen, I can start a second instance of my app.

And I guess this is exactly what @Pedro Caldeira means.

I also have a XIAOMI Redmi Note 10Pro smartphone. And this fact (the starting of a second instance of my app) is really stupid in the OS!

best regards
ARTsoft

Did you find a solution to this problem?
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
But when I remove my app from task list and click to the normal app icon which is located on my home screen, I can start a second instance of my app.
i think this is the point that closes the app.
if you click the icon now you will re-launch the app.
i have never seen an app that has more than 1 instance.

if you press the button to see all your running apps in the background to close them are you seeing your app twice?

i mean this screen:

can you see 2 instance of your app in this screen? if not then your app runs only once!

android-recent-apps-2.png
 
Upvote 0

Serge Bertet

Active Member
Licensed User
I don't think it is possible to run more then one instance of any app.
I agree with that.
When I was developping app for Windows using Delphi the solution was to write a key in Windows register at the begining and then remove it at the end.
A launched app reading that key stops immediately when reading this key.
Maybe it is possible to do the same using KVS.
 
Upvote 0

emexes

Expert
Licensed User
When I was developping app for Windows using Delphi the solution was to write a key in Windows register at the begining and then remove it at the end.
A launched app reading that key stops immediately when reading this key.

How did you handle situations where your app didn't finish normally (eg power failure) and thus didn't remove the registry key at the end?
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
Upvote 0

Serge Bertet

Active Member
Licensed User
How did you handle situations where your app didn't finish normally (eg power failure) and thus didn't remove the registry key at the end?
Never happened ... As I remenber Delphi apps have only one entry and exit point. But for sure in case of power failure, I don't know how to deal with that.
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
...but here the problem is an android app... i think if it is an app running at foreground do your job and then getting at home is the exit... is possible... but if runs and at back... seems that will never get a solution... except if you have exit button at app - and only this is the right "EXIT"..
 
Upvote 0

Spavlyuk

Member
Licensed User
Upvote 0
Top