2

In Phones Like Oppo and One Plus 6 some apps like Facebook and Whatsbook do not get closed from recent.

When I close all apps from recent, these 2 apps Facebook and Whatsapp remains there.

In the screenshot I have attached, we can see a lock at top right corner of facebook and whatsapp icons, but no lock on Videos Icon.

Android Version : 8.1 and above

My question is: How can I do that by code. How to prevent my app from being closed by user in/from Recent

screenshot

Community
  • 1
  • 1
  • THis is not a feature of Android. You can close facebook from recents, I just did it. If this was possible every app would have it on. – Gabe Sechan Sep 20 '18 at 04:21
  • Dear I have checked properly in Oppo and One Plus 6 I have, and then I posted this question. You can see the lock on icons of FB abd Wahtsapp but not on Videos app. – kamlesh yadav Sep 20 '18 at 04:47
  • That's a feature of their launcher app, and it isn't a feature of ANdroid in general. It may be that there's an SDK to do it, but it won't work in general and it may be using a whitelist. – Gabe Sechan Sep 20 '18 at 04:49
  • Thanks So any hint how can I do this ? Pls – kamlesh yadav Sep 20 '18 at 05:19

1 Answers1

4

You can't add this feature.

But if you wants prevent app kill from recent don't show in recent list

try excludeFromRecents (hack)

<activity
        android:name=".YourActivity"
        android:excludeFromRecents="true"/>

excludeFromRecents: Whether or not the task initiated by this activity should be excluded from the list of recently used applications, the overview screen.

Ranjithkumar
  • 16,071
  • 12
  • 120
  • 159