public void onSavePageAllScreenShot() {
handler.sendMsgQuick(6);
wv.setDrawingCacheEnabled(true);
Picture picture = wv.capturePicture();
int captureHeight = DEVICE_HEIGHT -255;
Bitmap saveAllScreenShot = Bitmap.createBitmap(picture.getWidth(), captureHeight, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas( saveAllScreenShot );
picture.draw( c );
SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyyMMdd_hhmmss");
Date today = new Date();
String strDate = formatter.format(today);
String dirPath = Environment.getExternalStorageDirectory().toString() + SAVE_FOLDER;
File file = new File(dirPath);
if( !file.exists() ) // 원하는 경로에 폴더가 있는지 확인
file.mkdirs();
File hFile = new File( "" + dirPath + "/SC_" + strDate +".jpg" );
FileOutputStream fos;
try {
fos = new FileOutputStream(hFile);
saveAllScreenShot.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.close();
} catch ( Exception e){
Log.i("error", e.getMessage());
}
wv.setDrawingCacheEnabled(false);
handler.sendMsgQuick(7);
}
}
'Android > 강의' 카테고리의 다른 글
TranslateAnimation를 이용한 이동 에니메이션 구현하기 (0) | 2017.06.28 |
---|---|
InputMethodManager를 이용한 시스템 키보드 숨기기 (0) | 2017.06.21 |
Handler를 이용한 Thread로부터 UI 접근하기 (0) | 2017.06.21 |
HttpURLConnection를 이용한 이미지 내려받기 (0) | 2017.06.21 |
HttpURLConnection를 이용한 JSP와 통신하기 (0) | 2017.06.21 |
댓글