Answer the question
In order to leave comments, you need to log in
How to get multiple images from gallery?
Good day everyone. There were two questions.
1. You need to get multiple images from the gallery.
what we do (I will give only part of the code so as not to clog):
- we hang on the button:
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType(IMAGE_TYPE);
//intent.setAction(Intent.ACTION_GET_CONTENT);
// this line is different here !!
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
startActivityForResult(Intent.createChooser(intent,
getString(R.string.no_task)), PICK_FROM_GALLARY);
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (data.getData() != null) {
try {
//Получаем URI изображения, преобразуем его в Bitmap
//объект и отображаем в элементе ImageView нашего интерфейса:
final Uri imageUri = data.getData();
final InputStream imageStream = getActivity().getContentResolver().openInputStream(imageUri);
final Bitmap selectedImage = BitmapFactory.decodeStream(imageStream);
imageView.setImageBitmap(selectedImage);
editTextScript.append(getPath(imageUri));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
//intent.setAction(Intent.ACTION_GET_CONTENT);
editTextScript.append(getPath(imageUri));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question