android에서 스크린샷은 스크린샷을 찍고자하는 activity를 불러와서 이를 bitmap 형식으로 변환, 원하는 포멧으로 저장하는 방법을 사용한다. 하지만 현재, 별도의 Camera device에서 android 폰으로 영상을 실시간으로 전송해서(byte arrary 형식) 폰으로는 볼 수 있는데, 해당 activity를 스크린샷 코드를통해 찍으면 검정색 화면만 나온다!
public void screenshot() {
View view = MyActivity.this.getWindow().getDecorView();
view.setDrawingCacheEnabled(true);
Bitmap screenshot = view.getDrawingCache();
String filename = "screenshot.png";
try {
File file = new File(Environment.getExternalStorageDirectory(), filename);
// File file = new File(Environment.getExternalStorageDirectory()+"/추가경로/", filename);
f.createNewFile();
OutputStream outStream = new FileOutputStream(f);
screenshot.compress(Bitmap.CompressFormat.PNG, 100, outStream);
outStream.close();
} catch (IOException e) {
e.printStackTrace();
}
view.setDrawingCacheEnabled(false);
}
}
뭐가 문제인지 찾아봐야겠다.
'android' 카테고리의 다른 글
[android] android code 안에서 adb 를 이용한 screenshot 찍기 (0) | 2016.02.03 |
---|---|
[android] switch vs if else (0) | 2015.01.29 |
[android]다른 프로젝트의 Activity 불러오기 (0) | 2015.01.29 |
[android]URL ImageView 생성 (0) | 2015.01.27 |
[android]AlertDialog ListView 예제 (0) | 2015.01.20 |