Android第一个程序截图,java – 在Android上截取屏幕截图

这是一个安全漏洞.你应该有一个root设备才能做到这一点.

// image naming and path to include sd card appending name you choose for file

String mPath = Environment.getExternalStorageDirectory().toString() + "/" + ACCUWX.IMAGE_APPEND;

// create bitmap screen capture

Bitmap bitmap;

View v1 = mCurrentUrlMask.getRootView();

v1.setDrawingCacheEnabled(true);

bitmap = Bitmap.createBitmap(v1.getDrawingCache());

v1.setDrawingCacheEnabled(false);

OutputStream fout = null;

imageFile = new File(mPath);

try {

fout = new FileOutputStream(imageFile);

bitmap.compress(Bitmap.CompressFormat.JPEG, 90, fout);

fout.flush();

fout.close();

} catch (FileNotFoundException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

尝试查看此代码以获取其他帮助:

附:可以使用DDMS从Android获取屏幕截图,但这是另一个故事.

P.P.S.如果你想在你下面的活动上透明地绘制你的启动器,你需要将像素格式设置为RGBA(仅处理OpenGL)并相应地渲染.您无需截取底层活动的屏幕截图即可.

root设备:在root设备上使用此代码:

process = Runtime.getRuntime().exec("su -c cat /dev/graphics/fb0");

InputStream is = process.getInputStream();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值