Why i cant Fetch the Gallery From my Desktop

17 views Asked by At

Its showing device folder when i am trying to upload an image

i tried to upload the image but its not working Here is the code

//is there any Error in this code?

private void openGallery() {
    Intent pickImage= new Intent(Intent.ACTION_PICK,MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    startActivityForResult(pickImage,REQ);
}



@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if(requestCode == REQ && resultCode == RESULT_OK){
        Uri uri=data.getData();
        try {
            bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(),uri);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        noticeImageView.setImageBitmap(bitmap);
    }
}

}

0

There are 0 answers