How to change the snapshot shown by recent apps list?
Asked Answered
S

3

13

In the newer versions of Android (> 3.0) there is an onscreen button that will display a list of the recent apps with their names and snapshots. Even though my app itself is password protected, this overview might show sensitive data in that snapshot. So is there any way to force a certain image (like a logo) to be shown rather than let the OS decide?

Synchronic answered 3/2, 2012 at 14:54 Comment(2)
Any other chance to achieve this ?Solicitous
Also see : #9822576Gormley
I
23

It seems to be impossible for now. There's a method called onCreateThumbnail but it is not used currently by the system I guess, since it is not called. I see two possible solutions:

1. To disable thumbnail on the activity containing sensitive data by adding FLAG_SECURE to your window: getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
2. To exclude your activities from recent apps, set android:excludeFromRecents attribute to true for activities in AndroidManifest.xml

Intemperate answered 10/2, 2012 at 9:25 Comment(1)
@Azat: In my app, I have functionality of setting/clearing FLAG_SECURE based on a user preference. It worked fine till KITKAT and black screen can be seen in task switcher if flags are set. In Lollipop, the Overview displays the last snapshot of my app(activity), the time when FLAG_SECURE was not set(cleared). stackoverflow.com/q/29564826/1263215Northerner
Q
4

The solution provided by Azat continues to be valid also in Lollipop.

Just a note, if you want to continue to not see snapshots in recent list for the entire app, ALL the implemented activities should specify in the onCreate() method the flag getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE); before setContentView();

Otherwise a snapshot in the recent list will show the first activity without the flag if the user navigated through it.

Quadrinomial answered 20/3, 2015 at 10:34 Comment(0)
A
-1

There is an approach to archive this requirement besides using that flag is HardwareKeyWatcher but it can not cover all of the cases due to fragmented device configurations and custom ROMs, then we have to fulfill missing cases with other approaches.

To ease the way of implementation, we had built a lib for Recent Apps thumbnail hiding mechanism, which supports implement a custom layout to show an empty screen with the app's logo when the app is going to Recents Screen.

Anacreon answered 9/9, 2021 at 15:1 Comment(2)
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From ReviewMonegasque
@IvanBarayev I added more detail into the answer.Anacreon

© 2022 - 2024 — McMap. All rights reserved.