0

Im creating a simple application that converts the image dimensions to a size that the user wants, im laying it out over a 3 screens the first screen allows a user to select an image and it is displayed on screen. the second screen then displays the attributes of the file (path, name, height and width) with the option of adjusting the name, height and width. the third screen displays the resized image with an option to save the new image. at the moment im only passing the image url between the classes and decoding the bitmap within each class eg

Bitmap bmap = BitmapFactory.decodeImage(image_URL);

my question is it better to pass the URL between the classes or pass the Bitmap?

many thanks

3 Answers3

2

You have several options:

  • Share the image through static data - Preferably in your Application class. Example: Using a class to store static data in Java?
  • Pass the image through the Intent data which is possible, but highly discouraged.
  • Pass the URL as you suggest and re-open and resize it each time.
  • Use a combination. For example, you should pass only image information to your second screen which displays said information.

I suggest that the first bullet is best practice and will work well for you.

Community
  • 1
  • 1
David Manpearl
  • 12,362
  • 8
  • 55
  • 72
0

That should be the correct approach. Passing Bitmap shouldn't be done from one activity to another. Passing the path is always recommended

Kumar Bibek
  • 9,016
  • 2
  • 39
  • 68
0

I think that dependent on where is your image if (you have the image on device ) I think the best is to pass Image path , but if you have the image on web and you have to download it I think passing bitmap is better than pass URL(Just to decries internet connection & faster for the user )

Developer So far
  • 353
  • 1
  • 11