android 拍照后保存图片(2) onActivityResult

rookieding 2011-10-21

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
                super.onActivityResult(requestCode, resultCode, data);

                Bundle extras = data.getExtras();

                Bitmap b = (Bitmap) extras.get("data");

                // img.setImageBitmap(b);
                
                if (b != null) {

                        try {
                                BufferedOutputStream bos = new BufferedOutputStream(
                                                new FileOutputStream(android.os.Environment
                                                                .getExternalStorageDirectory()
                                                                + "/a.jpeg"));
                                b.compress(CompressFormat.JPEG, 75, bos);
                                bos.flush();
                                bos.close();
                        } catch (Exception e) {
                              
                                e.printStackTrace();
                        }

                }
}
 

相关推荐