Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When does Android take its recent apps switcher screenshot?

Tags:

I am developing an app that has private information and should not display a real screenshot in Android's recent app switcher. I've tried a variation of this solution, by setting the content view to an ImageView inside the onPause function, but it seems that the operating system takes a screenshot before the content view is changed to the custom image.

I am also aware of setting the window's layout parameter flags to secure, making the screenshot completely white, but I'd hope that there would be a way to customize the screenshot.

So, I'm wondering at what point that Android takes a screenshot of the app for the app switcher (specifically in KitKat and Lollipop).

like image 621
Louie Bertoncin Avatar asked Jun 23 '15 19:06

Louie Bertoncin


People also ask

What is recents screen?

The Recents screen (also referred to as the Overview screen, recent task list, or recent apps) is a system-level UI that lists recently accessed activities and tasks. The user can navigate through the list and select a task to resume, or the user can remove a task from the list by swiping it away.

How can I see when an app was last opened?

You'll be able to see your recent apps with a single tap. From the Home screen, tap the Recents icon to the left of the Home button. All of your active or opened apps will be listed. If you've customized your Navigation bar, Recents may be located on the right, unless you're using full screen gestures.

Can Android apps take screenshots?

On many Android devices, you can capture a screenshot with a key-combination: Simultaneously press-and-hold Power and Volume-down. You can also capture a screenshot with Android Studio as follows: Run your app on a connected device or emulator.

What is Samsung recents button?

The Recents key — the square you see in the bottom-right corner of most Android phones — is a staple of the OS, letting you see a card-deck of recently-used apps.


1 Answers

EDIT

It is no longer possible to customize the screenshot which system uses to present the thumbnail in the recent apps.

Old answer

Take a look at method Activity.onCreateThumbnail - this is exactly what you're looking for as it let you draw your own thumbnail for Recent screen.

You get Canvas as one of the parameters in which you can draw (or not draw at all) directly. The main point is that you have to return true from this method, which indicates that system won't draw thumbnail itself.

The simpliest solution would be:

@Override public boolean onCreateThumbnail (Bitmap outBitmap, Canvas canvas) {     // Do nothing or draw on Canvas     return true; } 

or if you want to draw your own Bitmap

@Override public boolean onCreateThumbnail (Bitmap outBitmap, Canvas canvas) {     Bitmap myBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.myBitmap);     canvas.drawBitmap(myBitmap, 0, 0, null);      return true; } 
like image 143
Dmitry Zaytsev Avatar answered Sep 20 '22 23:09

Dmitry Zaytsev