I want the app to be unclosable. I noticed that it can be done if im pressing on the lock button in the recent app screen. Is there any way to lock it programmatically when the app is running?
Asked
Active
Viewed 2,516 times
0
-
Why do you want to do that? It's a bad user experience. – Pradeep Simha Sep 03 '18 at 19:04
-
This app is for self-use only, the point is that i want that it will be hard to close the app. @PradeepSimha – Ohados Sep 03 '18 at 19:11
-
Sometimes it switches to locking state spontaneous, immediately after installing from Play Market. I'm having it issue approximately in 2% my app's installs. – Alexander Kiselev Mar 03 '20 at 09:06
1 Answers
2
This is not possible to do.
That lock icon is a feature of whatever phone you are running, not built into Android.
Alternatively, you can use a foreground service to continuously check if your activity is open, and if it gets closed then re-open it.

Shmuel
- 3,916
- 2
- 27
- 45
-
Hey, thanks alot for the answer. Can you link me to a service that does that? Thanks. @Shmuel – Ohados Sep 03 '18 at 20:20
-
Use this as an example: https://stackoverflow.com/questions/18276355/how-to-keep-a-foreground-app-running-24-7 – Shmuel Sep 03 '18 at 20:22
-
@Shmuel https://www.techrepublic.com/article/how-to-make-use-of-the-android-nougat-recent-apps-lock/ according to this article lock recent apps is implemented since android nougat, I hope it means this is not phone specific but OS specific feature – metvsk Dec 08 '21 at 05:13