Here came the task: You need to perform the usual intent to select a picture from the gallery. In the usual ImageView in the application, you need to insert a picture in a thumbnail, and save the original for further processing. You also need to provide for downloading large images.

Can you tell me how to organize the UI and how to compress the image and place it in the ImageView and keep the original?

    1 answer 1

    To upload a picture from the gallery, you need to send a similar content to the system:

     Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); Intent chooserIntent = Intent.createChooser(intent, "Выберите изображение"); startActivityForResult(chooserIntent, FILE_SELECT_CODE); 

    The system will return the Uri selected file.

     protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case FILE_SELECT_CODE: if (resultCode == RESULT_OK) { Uri uri = data.getData(); if (uri != null) { // TODO: вот выбранный файл } } } } 

    Uri will look like "context: \ ....." You can get a data stream from it like this:

     InputStream fileStream = null; try { fileStream = getContentResolver().openInputStream(uri); } catch (IOException e) { Log.e(this.getClass().getName(), e.getMessage()); } 

    How to work effectively with pictures and upload them in the desired resolution is well described here: http://developer.android.com/training/displaying-bitmaps/load-bitmap.html

    BitmapFactory can work not only with application resources, but also with files and streams.