当前位置: 代码迷 >> Android >> android 照相后保存图片(2) onActivityResult
  详细解决方案

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

热度:37   发布时间:2016-05-01 19:10:48.0
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();                        }                }}
?
  相关解决方案