Android - Taking photos and saving them with a custom name to a custom destination via Intent

前端 未结 3 861
日久生厌
日久生厌 2020-11-28 10:41

I have a program that opens the camera via Intent to take a photo. That much part works fine already. However, I want it to save to a certain folder with a certain file name

3条回答
  •  有刺的猬
    2020-11-28 11:25

    this may help u

    File file=new File(Environment.getExternalStorageDirectory(),"file name");
    
    button.setOnClickListener(new OnClickListener() {
    
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            opencam();
        }
    });
    
    protected void opencam() {
        Intent in = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);    
        in.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(file));
        startActivityForResult(in,1);
    }
    

提交回复
热议问题