Android 调用系统相机拍照并获取原图

第一步:调用相机

Intent getImageByCamera = new Intent(
                        android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                String path = Environment.getExternalStorageDirectory()
                        + "/path";
                File f = new File(path);
                if (!f.exists()) {
                    f.mkdirs();
                }
                String fileName = System.currentTimeMillis() + ".jpg";

                filePath = path + "/" + fileName;
                DevLog.e(filePath);
                File file = new File(path,fileName);
                Uri u = Uri.fromFile(file);
                getImageByCamera.putExtra(MediaStore.Images.Media.ORIENTATION,
                        0);
                getImageByCamera.putExtra(MediaStore.EXTRA_OUTPUT, u);
                startActivityForResult(getImageByCamera, 1);

第二步:根据以上保存图片的路径在onActivityResult方法中根据保存路径获取拍照后的原图。

posted on 2015-12-03 10:18  飘杨......  阅读(910)  评论(0编辑  收藏  举报