Get android gallery photo directly

1

I've researched here and elsewhere on the internet, but I could not find anything like that. Is it possible to restrict that the photos selected by a user come only from the gallery? Ex: When I click on a profile photo and choose the gallery option I will be directed directly to the photos that are in the gallery and select any one.

    
asked by anonymous 18.05.2016 / 22:52

1 answer

3

Try the following:

Open option:

 public static final int PICK_IMAGE = 1234;
 Intent i = new Intent(Intent.ACTION_PICK,
            android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
    startActivityForResult(Intent.createChooser(i, "Selecione uma imagem"), PICK_IMAGE);

Image reception in Activity:

 @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if(resultCode != Activity.RESULT_CANCELED){
            if(requestCode == PICK_IMAGE){
                Uri selectedImage = data.getData();
                Toast.makeText(getApplicationContext(), selectedImage.toString(), Toast.LENGTH_SHORT).show();
            }
        }
    }
    
20.05.2016 / 15:58