1

Can anybody tell me that what is the alternate/ updated option of GALLERY_PICK, because GALLERY_PICK option is not coming in startActivityForResult parameter. I googled it but I'm not getting any solutions. Actually I want to choose images like we do in WhatsApp when we have to send any particualr image from our gallery.

ChatActivity.java

plus.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setType("image/*");
                intent.setAction(Intent.ACTION_GET_CONTENT);
                startActivityForResult(Intent.createChooser(intent,"Select image"),GALLERY_.....);
            }
        });

Here, plus is a button in my xml file and I did findviewbyid in ChatActivity.java

  • Simple use the answer I provided here, it's does what you want also and even give better image quality, so you can choose from gallery and even google drive and many more. https://stackoverflow.com/a/51335137/7667720 – Wale Jul 14 '18 at 14:36
  • Sorry, but I don't want to use that library. please tell me that why option is not coming? –  Jul 14 '18 at 14:37
  • You mean to show options between camera and other options? or just from the select option to show other drives to select from? – Wale Jul 14 '18 at 14:47
  • 1
    After running your code, startActivityForResult(Intent.createChooser(intent,"Select image"), 1); I got options to select from other drives like gallery, google drive and many more... – Wale Jul 14 '18 at 14:48
  • "I got options to select from other drives like gallery, google drive and many more" excatly but why I'm not getting, why I'm complier shows error? and what is "1" here? –  Jul 14 '18 at 14:50
  • "I got options to select from other drives like gallery, google drive and many more" exactly I want this –  Jul 14 '18 at 14:51
  • 1 is simply the request code as I have always been told but have not be chanced to confirm how it helps yet, but with that you should not get the runtime error anymore.??? – Wale Jul 14 '18 at 14:54
  • So you mean to say that instead of GALLERY_PICK option,we can use "1" ? –  Jul 14 '18 at 14:56
  • It's the same!!! if you check the value for the GALLERY_PICK, should be 1, and if you don't mind show me the runtime error? – Wale Jul 14 '18 at 14:58
  • forget about run time error, first that option itself not coming it means if I hardcore GALLERY_PICK it is showing complier error –  Jul 14 '18 at 14:59
  • The fact is that either hardcoded or not! if the value is 1, then you should not have issues there! if only there is error somewhere else entirely! error might come from the onActivityResult! so showing the error code will enable me trace the crash. – Wale Jul 14 '18 at 15:03
  • Okay, if it crash, I'll get back to you –  Jul 14 '18 at 15:06

1 Answers1

0

add this to your code

private static final int GALLERY_PICK = 1;
Derry
  • 11
  • 3