Importing galleria images into the Android app

1

I am putting together an App in which I want it to allow, through a button, that I choose images from the gallery and include and save within the application. But I have a problem with IMAGE_GALLERY_REQUEST because NetBeans says it can not find the symbol. I'm kind of lazy on the subject so I ask you to be as clear as possible in the answer. Thank you.

    public void onImageGalleryClicked(View v) { 

    Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
    File pictureDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
    String pictureDirectoryPath = pictureDirectory.getPath();
    Uri data = Uri.parse(pictureDirectoryPath); 
    photoPickerIntent.setDataAndType(data, "image/*"); 
    starActivityForResult(photoPickerIntent, IMAGE_GALLERY_REQUEST); 

}
    
asked by anonymous 23.01.2016 / 17:35

1 answer

3

The second method parameter startActivityForResult () is an integer to identify this" request ".

startActivityForResult ( ) is used in conjunction with the onActivityResult () that will be called after the launched Activity is terminated.

You can only have one onActivityResult () in each Activity, this identifier is used to know what startActivityForResult() has called it.

Change

starActivityForResult(photoPickerIntent, IMAGE_GALLERY_REQUEST); 

for

starActivityForResult(photoPickerIntent, 1); 

or declare the constant IMAGE_GALLERY_REQUEST :

protected final static int IMAGE_GALLERY_REQUEST = 1;
    
23.01.2016 / 18:18