화면을 캡쳐한후 sdcard에 저장하고 싶습니다..
그런데 동작이 되지않는데 뭐가 문제인지 찾을 수가 없습니다 ㅠㅠ
조언좀 해주세여!!!
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
public class Browsertest2Activity extends Activity {
LinearLayout view;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
view = (LinearLayout)findViewById(R.id.screen);
Button myBtn = (Button)findViewById(R.id.myBtn);
myBtn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
View v1 = view.getRootView();
System.out.println("Root View : "+v1);
v1.setDrawingCacheEnabled(true); //캡쳐할수 있도록 권한 설정
v1.getRootView().buildDrawingCache(); //화면 캡쳐해서 비트맵으로 가져오는 부분
Bitmap bm = v1.getRootView().getDrawingCache();
System.out.println("Bitmap : "+bm);
try{
FileOutputStream out = new FileOutputStream("/sdcard/captureScree.png");
bm.compress(Bitmap.CompressFormat.PNG,100,out);
}catch(FileNotFoundException e) {
Log.d("FileNotFoundExeption:",e.getMessage());
}
}
});
}
}