Show custom application image in task manager on ICS or JB

让人想犯罪 __ 提交于 2019-12-01 16:52:23

问题


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:

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.

来源:https://stackoverflow.com/questions/12639335/show-custom-application-image-in-task-manager-on-ics-or-jb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!