-1

This below code is pick image from device. how to pick pdf from device.and how to show a pdf in Image view?

  bt_gall .setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent();
                    // Show only images, no videos or anything else
                    intent.setType("image/*");
                    intent.setAction(Intent.ACTION_GET_CONTENT);
                    // Always show the chooser (if there are multiple options available)
                    startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);
                    alertDialog.dismiss();
                }
            });
VivekRatanSinha
  • 596
  • 1
  • 4
  • 17
spodee
  • 54
  • 1
  • 6

1 Answers1

0

To select pdf Try This

Intent intent = new Intent();
        intent.setType("application/pdf");
        intent.setAction(Intent.ACTION_GET_CONTENT);
        startActivityForResult(Intent.createChooser(intent, "Select PDF"), 1);

To Set Pdf as image you need to create thumbnail of pdf

To create Thumbnail Check This,

https://stackoverflow.com/a/38829523/3416642

Hope this will help you.

Community
  • 1
  • 1
Sachin
  • 1,307
  • 13
  • 23
  • in example, when i press the button i want to choose both image file or pdf file.what is the code? – spodee Apr 18 '17 at 09:27
  • @spodee pass multple MIME type - Check This http://stackoverflow.com/a/33117677/3416642 – Sachin Apr 18 '17 at 09:30
  • when i try this code [Intent intent = new Intent(); intent.setType("image/*|application/pdf"); intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(Intent.createChooser(intent, "Select Document"), 1);] only image wass selected. – spodee Apr 18 '17 at 09:46