0

Everything works fine except image updation! When I register a new user and when I click in the image, it opens my image gallery, I choose any image, and it back to register activity but it won't update. Also I'm unable to register because that image is not uploading successfully and we sat if imagepath == null, show that's why toast error is coming that fill all the details.

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if(requestCode == PICK_IMAGE && requestCode == RESULT_OK && data.getData() !=null){
            imagePath = data.getData();
            try {
                Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), imagePath);
                userProfilePic.setImageBitmap(bitmap);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        super.onActivityResult(requestCode, resultCode, data);
    }

NOTE:

  1. I tried multiple images, same issue.

  2. There is no error in logcat.

  3. Default image is showing perfectly when we first time try to register that time we sat android logo which is a default.

  4. I can't register without selecting any image because image path == null.

  5. No problem of image size.

Guys, any solution?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
  • 1
    `requestCode == PICK_IMAGE && requestCode == RESULT_OK` is it correct? I think it is resultCode == RESULT_OK. – Liem Vo Jun 25 '18 at 10:21
  • @saransh try this https://stackoverflow.com/questions/10473823/android-get-image-from-gallery-into-imageview – Rajesh Jun 25 '18 at 10:28
  • follow this answer [Pick image using FileProviders](https://stackoverflow.com/questions/49685461/fileprovider-is-very-confusing/49685978#49685978) – Mohammed Farhan Jun 25 '18 at 10:45
  • As mentioned by @Liem Vo, please check your 2nd condition ie requestCode == RESULT_OK..it should be resultCode == RESULT_OK – Man Jun 25 '18 at 11:12

0 Answers0