how to save capture image in sdcard?

后端 未结 6 2101
旧巷少年郎
旧巷少年郎 2021-01-27 11:19

I want to use default camera and capture image. i want save image in sdcard/photofolder/ and save filename as curenttime format in sdcard/photofolder/ also display capture imag

6条回答
  •  情深已故
    2021-01-27 11:34

    Try this

    private void cameraOn() {
                tempUri = "sdcard/......";
            i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            i.putExtra(MediaStore.EXTRA_OUTPUT, tempUri);
            startActivityForResult(i, cameraData);
        }
    

    To get the bitmap

    @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            switch (requestCode) {
            case cameraData:
                if (resultCode == RESULT_OK) {
                    Bitmap bmp = BitmapFactory.decodeFile(tempUri.getPath(), null);
                    imageShow.setImageBitmap(bmp);
                } 
                break;
            }
        }
    

提交回复
热议问题