Android : multiple images required for an application - android

Is it ok to have lot of images in your application .. If an app has say 1K photos and if i have that images in hdpi,ldpi,mdpi,xhdpi,xxhdpi .. it will be a size issue for the app ..
So it's better to have a web view loading image from url or storing images in app?

As long as the images are not really excessively large, it's better to store in an app, I think:
you won't need internet permission
this will be much faster to display to the user which will result in a better user experience

Related

Android Programming Working with Lots of Images

Newbie in Android Development. Just looking for suggestions. I want to develop an android app which will display lots of images to user (upon clicks or swipe). In other words user should be able to browse lots of images which are provide by the app (not on the user phone). An example would be existing android app for inspirational quotes etc.
I wonder where all those images would be saved at the developers end?
What would be the fastest way to allow user to browse these images?
Are there any online example/tutorial for this?
I saw few tutorials but they were only for 5-6 images, but what I need to provide user is 500-1000 images or even more (will be adding if the app is successful).
Any pointers would be highly appreciated.
Possible ways are
To store those images on server and load it from Server URL.
And you can use Picasso to load those images with following code
com.squareup.picasso.Picasso.with(context).
load(imaegPath).
placeholder(R.mipmap.ic_launcher).
into(imageView);
here imagePath is the URL of image.
For more details on Picasso read this answer
But for that you need internet connection.
NOTE : This may not be the fastest way to load images as it depends on internet connection.
You can store images in resources directory and load the images.
imageview.setImageResource(R.id.image1);
But if images size is large, your app size will be accordingly.
It seems that you need large size of memory, and strategy for control that.
First, I suggest you to get your memory class. memoryClass shows you how much memory your app can use. With this value, you can determine your image cache amount.
ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
int memoryClass = am.getMemoryClass();
Log.v("onCreate", "memoryClass:" + Integer.toString(memoryClass));
See Also: Detect application heap size in Android
Second, ImageView of Android 2.2 and 2.3 has memory leak. (Well, these versions are now very old and hard to find)
Android bitmap imageview memory leak
You can download this example:
https://github.com/StanleyKou/GettyImageViewer
In this example, you can see how to use picasso library with many images from website.

Image strategy on Android

I am creating an application with lots of photos. They will take > 100 mb on memory. So far I have 3 ideas:
Place it in #drawable - app will be heavy
Download by JSON and place in java array - cashing - How long it can be there?
Download by JSON, place it on phone memory/SD card and read in application from memory. User can Remove pictures.
The best option will be to give possibility to user if he want to have a pictures or not.
What strategy is most efficient and recommended?
Every opinion and tutorial will be helpfull.
Thanks
There are a lot of library that do the work of downloading the images from web and then cache them in your preferred memory for you. Some of them would be:
1. nostra13 / Android-Universal-Image-Loader
2. Square / Picasso
3. Google / Volle
I wrote a blog post on this subject that you can check:
How to load images asynchronously into a ListView
Check out Android Image Loader, it can also cache the images for you to prevent re-downloads in the future. It has many other features also.
Easy to use too, can load an image from a url into a view by simply using:
imageLoader.displayImage(imageUri, imageView);

Idea to download images in android

I'm making an android app, here the images are getting from Cloud, is it good idea to download images and save it & use it further. Or download images every-time user uses the app, what idea you prefer is the best?
Because downloading images always is slow & its bad i know but at some point if the images are updated then how to get to know about it?
You should definitely cache your downloaded files!
Do it in your internal app directory where only you do have access to (or otherwise external storage, thats still ok).
Bandwidth and connections are always expensive and should kept low as much as possible.
So your user can see images fast even on a bad connection and your app doesn't waste his valuable bandwidth of a users data plan.
Maybe this could also help you:
https://github.com/novoda/ImageLoader
http://www.androidhive.info/2012/07/android-loading-image-from-url-http/
Make it easy on yourself and use something like Android Smart Image View. It takes care of loading and caching, and it's just about a drop-in replacement for Android's ImageView. Universal Image Loader is another alternative, more configurable, but not as quick to implement.
I used https://github.com/nostra13/Android-Universal-Image-Loader
but I think you not want only download and cache.
these no trick ,if you want check weather the image update or not, you can add metadata for image, just like md5 .
in html and browser, you can set expires header for a image:
enter link description here
but in android app, you control all yourself.
Downloading images and saving them is probably the best way to do it because you don't want to download the same images over and over. If the images are updated you can delete the older one and download the new ones. Just make sure you don't download/save a million images. Take a look at this library. It has a built-in cache on sdcard/external sd.
Downloading images from the net for display, with possible requirement of caching is a very common problem that many people have solved, you can try these solutions to see which fits you:
Ion (https://github.com/koush/ion) - very flexible and feature complete, plus it can download more than images but JSON, Strings, Files, and Java types as well. The part that I really like about this is that it can automatically cancel operations when the calling Activity finishes, so users don't waste time & bandwidth downloading images that will no longer be displayed
Universal Image Loader (https://github.com/nostra13/Android-Universal-Image-Loader) - equally capable for most use cases but for downloading/caching images only

The Best Way To Load Multiple Large Image in a GridView

My Problem deals with Memory, I have a Web service that provide me a List of Urls. Each URL corresponds to a large image. My Mobile app have to parse the xml provided by the web service and than show in a GridView these images. I tried several features in order to display images such as:
Multithreading
Lazy Loading
Reduce image size using inSampleSize ( this causes my app takes too long)
should i have to attach for each large image a thumbnail image, and make the web service return to me the list of all thumbnails, after that show these thumbnail to the user, and if he clicks on one of them than i have to show the large image in a separate view, i have this idea because i noticed when i show one image i don't get an outofMemory exception!!
Is this a reliable solution? is there a better way?
Welcome to one of the hardest issues on Android. First I would start by reading this new documentation google wrote on how to handle bitmaps. Its not a light read, but you probably need to read it all the way through. It has only been up for a few weeks so you may not have seen it. It details many of the things you mentioned such as multithreading, lazy loading, and down sampling. They also recommend using an image cache.
Downloading the large images for each image and then down sampling is going to be very inefficient. First the download size is larger than needed. Second you need to load it into memory to perform the down sample and third down sampling is somewhat slow.
I would have the web api return you a list of thumbnail urls and full image urls that you can lazy download as the view comes on screen and use the cache to keep them around a while. Make sure you down sample the sizes of the thumbnails as well. I would then when the user clicks on an image go download the full image and on the background when it arrives down sample it before displaying it.

How to handle large images in android

i'm writing a simple application. i need to handle around 100 images having size dimension 1000*740. images are fixed no need to change. user will see this images like gallery view.
Problem
1.Large number of Images increases .apk filesize .It crosses memory limit(Given by Android market).
2.I placed these images in Drawable folder.Is there any other way to keep this images?
Any Idea?
YOu can host them on a separate site, but you do not have to download them every time. You can download them to an external directory (sd card) and just check if you've got everything you want when starting the app: If you do, you obviously don't have to re-download the shots again.
Is there a reason your images are of that size? If you compress them a bit you should be able to fit a photo in less then half an MB, and I think that the limit is 50mb on the market: You might be able to just squeeze it in.
Upload all the images to a link. Do parsing by using that link.
That's a pretty tough dilemma. Perhaps the user can download the images instead. You could use flickr to host the images.
I would suggest hosting them somewhere and download as "citizen conn" suggested.
Another possibility would be to separate in different sets and have different apk with those (maybe some of them would only have a content provider with some of those pictures). But that's kind of ugly...
Other than that, I don't think there is any way to get around the limit from Android market...

Categories

Resources