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
Related
My app uses images from a URL and I want to reduce resources usage for both server and client.
I wonder if the Android SDK already offers something for this (if there's some standard way to do it) or I just have to figure it out.
What I have in mind is:
download images on local storage (external or internal) when accessing content (lazy loading, progress bar) and keeping them there for next use
update images (download and replace) if changed on server (keep checksum in a database that is queried when the application is started)
in order to avoid excessive local disk usage (they are quite big), delete images for content that has not been accessed for N days. This is done while loading the app or in a background asynchronous service
Should I do this step by step or is there something that already takes care of it. Are there libraries to do this properly?
I think Picasso library is best for this, it has many capabilities and is really easy to use, its features include smooth image caching (the features you need), image processing and Async downloading from URL too. It has so many useful features.
Here is its url link
http://square.github.io/picasso/
I want to save the images fetched from server for once and from next time i want to check first whether images are stored or not in device, if not then again it should fetch from server and store in user's device again, and if yes then application will use images directly rather than fetching from server again and again. It will be useful for enhancing the speed of application. Basically my application is fetching multiple images from server so i want to save those images on user's android device and from next time application should fetch from device. I think you got my question.
The simple way:
You can use Picasso.
It is a simple lib which provides image downloading and caching.
In my opinion it might not be the fastest, but it is pretty simple and intuitive. It does its job well and none who I asked complained about it.
Picasso
Other libs:
UIL
Volley
Glide
fresco
To make it short. There are lots of other libs. An awesome comparision of the most Populat ones can be found here and here
The do it yourself way:
You can also write you own caching logic with a LRUCache. Which is also pretty simple.
Take a look at:
https://developer.android.com/topic/performance/graphics/cache-bitmap.html
The LRUCache is just a Memory Cache so you might also want to use a DiskLRUCache
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);
I'm going to be making a wallpaper app but need some guidance on how I am going to be able to store, retrieve and view the wallpapers.
Will I need to make use of ImageView so I will be able to display the images?
I'm going to need some sort of database/website to store all of the wallpapers on. What would be the best thing to do, use a database or a website?
How would I go about retrieving the wallpapers from my chosen source?
Any help/advice would be appreciated, thanks.
A common practice is to use an rss feed of images. Then, just hook up your app to the rss feed and have it check for updates periodically.
Here is a reference on reading xml (rss) in Android:
http://www.ibm.com/developerworks/opensource/library/x-android/index.html
Good luck.
you can try aquery android library for lazy loading image. this library store images in cache memory so you not need to store it externally also it will take some time for first time loading image from web but once it load in your application then it will automatically store in cache so second time take very less time to display also its less time consuming then other lazzy loading methods..below code may help you.....
AQuery aq = new AQuery(mContext);
aq.id(R.id.image1).image("http://data.whicdn.com/images/63995806/original.jpg");
You can download library from from this link
Personally I would use a database. But the easiest option would be to use the 'res/drawable' folder in android I guess.
If you stored them on the internet and haven't got connectivity, you can't get your images, so users won't necessarily like this.
To get at them from a database you'll likely have to know some SQL or know someone who knows a bit of SQL. The advantage of storing them in a database would be that it's one neat package and it is portable.
Don't worry about using ImageView it, you just need to get the image from the source (database /filesystem etc..) and give it to the imageView
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...