Photo by Camera Upload Exception (Firebase Storage)

后端 未结 3 1973
时光说笑
时光说笑 2021-01-25 04:28

I\'m trying to upload an image taken by the camera in an android application to Firebase storage. The problem is that after I take the picture, in the confirmation activit

相关标签:
3条回答
  • 2021-01-25 04:44

    The exception occurs because the Uri in onActivityResult() is null:

    Uri uri = data.getData();
    

    The documentation for capturing a camera image explains:

    The Android Camera application saves a full-size photo if you give it a file to save into. You must provide a fully qualified file name where the camera app should save the photo.

    Follow the example in the documentation to create a file Uri and add it to the intent for the camera app.

    0 讨论(0)
  • 2021-01-25 04:48
    if(requestCode == CAMERA_REQUEST && resultCode == RESULT_OK){
            Bitmap mImageUri = (Bitmap) data.getExtras().get("data");
            select.setImageBitmap(mImageUri);
        }
    

    then start posting

    0 讨论(0)
  • 2021-01-25 05:07

    Please try this

    Intent intent = new Intent(Intent.ACTION_PICK,
                            android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                intent.setType("image/*");
                startActivityForResult(intent, GALLERY_INTENT);
    
    0 讨论(0)
提交回复
热议问题