private void takeScreenshot() {
try {
// image naming and path to include sd card appending name you choose for file
// 저장할 주소 + 이름
String mPath = Environment.getExternalStorageDirectory().toString() + "/" + now + ".jpg";
// create bitmap screen capture
// 화면 이미지 만들기
View v1 = getActivity().getWindow().getDecorView().getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
// 이미지 파일 생성
File imageFile = new File(mPath);
FileOutputStream outputStream = new FileOutputStream(imageFile);
int quality = 100;
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
outputStream.flush();
outputStream.close();
openScreenshot(imageFile);
} catch (Throwable e) {
// Several error may come out with file handling or OOM
e.printStackTrace();
}
}
출처: http://devuryu.tistory.com/48 [대부류 - [Dev u Ryu]]
setDrawingCacheEnabled
이부분인 deprecated 되었다고 나오네요