700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > Android第一个程序截图 java – 在Android上截取屏幕截图

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

时间:2021-07-10 09:32:47

相关推荐

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);

press(pressFormat.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();

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。