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

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();
                        }

                }
}
 

相关推荐