写了个while判断文件是否存在,存在的话改变命名。如下:

    class startButtonListener implements OnClickListener
    {
        int count = 0 ; 
        @Override
        public void onClick(View v) 
        {
            imageFilePath = destDirName + "/pic0.jpg";
            File imageFile = new File(imageFilePath);
            while(imageFile.exists())
            {
                count += 1 ; 
                imageFilePath = destDirName + "/pic" + count + ".jpg" ; 
                imageFile = new File(imageFilePath);
            }
            
            Uri imageFileUri = Uri.fromFile(imageFile);

            Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, imageFileUri);
            startActivityForResult(i, 1);
        }
        
    }

  

相关文章:

  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2021-08-08
  • 2022-12-23
猜你喜欢
  • 2022-01-01
  • 2022-02-27
  • 2022-12-23
  • 2022-01-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案