Show custom application image in task manager on ICS or JB
Asked Answered
L

0

6

As far as I see on Android 4.0 (or higher) default task manager shows last screenshot from program with program icon no the top left. See image:

screenshot

My question is how to change application's image (not icon) in task manager to custom? Don't ask me why, I just need it.

After some research I found similar question on SO: Show black preview screen in task manager on ICS. But it doesn't answers my question.

Also I didn't find any API to work with this task manager.

So I decided to show custom image when program (activity) turns off. From activity lifecycle I found that I need to override method onPause. So I decided to code a small program. It's very easy to understand:

public class MainActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void onResume()
    {
        super.onResume();
        setContentView(createImageView("/sdcard/program-image.jpg"));
    }

    @Override
    public void onPause()
    {
        setContentView(createImageView("/sdcard/task-manager-image.jpg"));
        super.onPause();
    }

    private ImageView createImageView(String pathFile)
    {
        ImageView imageView = new ImageView(getApplication());
        imageView.setImageBitmap(BitmapFactory.decodeFile(pathFile));
        imageView.invalidate();
        return imageView;
    }
}

The task-manager-image really shows for a while after pressing Home button, but task manager shows only program-image.

So is there any good solution to do this?

Thanks for any help.

Longwinded answered 28/9, 2012 at 11:41 Comment(3)
I doubt that there is a definitive time when it takes the screenshot. You can block the screenshots using FLAG_SECURE (see commonsware.com/blog/2012/01/16/secure-against-screenshots.html), and you can read the image from ActivityManager.RunningTaskInfo, but I do not believe that you can change the image via any public API.Denotation
@Denotation thanks for your reply. So how can I show some image for a second (or other time)? It seems to be the only solution now. Thanks.Longwinded
Again, the issue is that you have no control over the timing of when the screenshot is taken, so you have no idea when you need to be displaying that image.Denotation

© 2022 - 2024 — McMap. All rights reserved.