【发布时间】:2015-01-15 04:27:21
【问题描述】:
你好朋友我正在用 webview 制作一个应用程序 我想截取我的活动截图 目前我正在使用此代码来捕获图像
public Bitmap takeScreenshot() {
View rootView = findViewById(android.R.id.content).getRootView();
rootView.setDrawingCacheEnabled(true);
return rootView.getDrawingCache();
}
这是为了保存
public void saveBitmap(Bitmap bitmap) {
File imagePath = new File(Environment.getExternalStorageDirectory() + "/screenshot.png");
FileOutputStream fos;
try {
fos = new FileOutputStream(imagePath);
bitmap.compress(CompressFormat.JPEG, 100, fos);
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
Log.e("GREC", e.getMessage(), e);
} catch (IOException e) {
Log.e("GREC", e.getMessage(), e);
}
}
它有时有效,有时无效,我的意思是,有时我可以在画廊截图中看到,有时不 我想如果有任何选项可以显示捕获的屏幕截图 就像我们按下音量键+电源键时一样
主要问题是如何在拍摄时显示图像 或知道它是否被采取 提前致谢
【问题讨论】:
-
您可以尝试保存图片后打开对话框以显示结果。
-
你能给我一个示例链接吗谢谢我提前
标签: android screenshot