如何利用设备屏幕快照编程? [英] How to take snapshot of device screen programmatically?

查看:127
本文介绍了如何利用设备屏幕快照编程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要带我的设备屏幕的快照快照上的按钮点击。请提供一些链接code样品代替。

I want to take snapshot of my device screen's snapshot on Button click. Please provide some code sample instead of links.

在此先感谢。

推荐答案

我得到了我的问题的答案。 Actualy我得到位为空。但我找到了原因和解决方案。

I got the answer for my question. Actualy i am getting bitmap as null. but i found the reason and the solution.

View v = findViewById(R.id.attachments_list);
    v.setDrawingCacheEnabled(true);
    // this is the important code :)
    // Without it the view will have a dimension of 0,0 and the bitmap will
    // be null
    v.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
            MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
    v.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight());

    v.buildDrawingCache(true);
    Bitmap bitmap = Bitmap.createBitmap(v.getDrawingCache());

这篇关于如何利用设备屏幕快照编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆