0

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?

enter image description here

Ohados
  • 83
  • 3
  • 13

1 Answers1

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