-2

Am developing an android portal where am required to upload images of 5MB -8MB to server using web service. I have limited knowledge on Android development. Typically user upload one image per one activity. Could you please advise.

  1. Is it recommended to make image upload process as background thread or can we let him to wait till upload gets finished?
  2. What is suggested approach to compress size of image.
  3. What is regular approach for this kind of development?
Maddy
  • 3,316
  • 9
  • 37
  • 53

1 Answers1

1
  1. All network calls must be done in the background thread. So uploading an image must be done in a background thread. Thread or AsyncTask would do.

  2. Images are already compressed unless you want to change its compression type or resize it. Look into image processing library. Or use this method. From here. How to Resize a Bitmap in Android?

Bitmap b = BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length)
profileImage.setImageBitmap(Bitmap.createScaledBitmap(b, 120, 120, false));
  1. All use of web service should be done async, because it can take a while and you don't want the UI to freeze.
Israel dela Cruz
  • 709
  • 1
  • 4
  • 11