Built-in Camera, using the extra MediaStore.EXTRA_OUTPUT stores pictures twice (in my folder, and in the default)

后端 未结 3 1597
温柔的废话
温柔的废话 2020-12-08 02:52

I\'m currently developing an app which uses the built-in Camera. I call this snippet by clicking a button :

Intent intent = new Intent(\"android.media.actio         


        
3条回答
  •  盖世英雄少女心
    2020-12-08 03:30

    try this code:

     Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
    //Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    
    String path = Environment.getExternalStorageDirectory().getAbsolutePath();
    path += "/myFolder/myPicture.jpg";
    File file = new File( path );
    //file.mkdirs();
    Uri outputFileUri = Uri.fromFile( file );
    //String absoluteOutputFileUri = file.getAbsolutePath();
    
    intent.putExtra("output", outputFileUri);
    startActivityForResult(intent, 0);
    

提交回复
热议问题