Android: How to check a modified status of image on web - android

I'm developing an Image Manager in Android. It will always check images in servers to draw...
I use a Disk-cache to cache images in SDCARD, and i must refresh them by cycles for some minutes..
But, Performance is not good if always update non-changed files.
How to check a changed status of an image? I want only get changed-files...
Can get a hash-code of image? or check-sum code?
I thinked a soluton: create a XML file on server, that stores all hash-sum list...
But, it not possible... so, Images are stored in many many sites...
thanks!!!

A simple solution:
Attach a time stamp to each image every time it is updated/modified.
On each refresh cycle, get only the time stamps of images and compare with timestamps of images on device.
Only download images which have timestamps greater than that of the corresponding cached images.
This way, you'll only be downloading text data (very small in size) in each cycle and image downloading will only be done when it is necessary.
You can also wire up your backend server to respond to a REST API and return only the updated images. The decision on whether to handle the calculations and logic on client side or server side will need considerations of the tradeoffs involved and will depend a lot on your apps specific requirements.

Related

Firebase Data Loading Speed

I'm developing an android app using Firebase back-end. Everything works fine, I have no problem whatsoever. The only problem is that, the data loading speed. Because it's a cloud-based system, sometimes it takes 4-5 (or even longer) seconds to load a user profile picture or simply to pull username from the database to display user. Now, you might say, well we don't even know how your data structure is stored in the no-SQL table but really I can't go wrong with that. I just structured it in a way that it's just a simple one read query. Or is it normal? Maybe Firebase loads data with some delay.
How you as other developers, get over this loading time? For example, I have a user picture, where the pic should be loaded from the Firebase database, but till pic is loaded, the image-view is just staying as a black view.
All of this depends on several factors that you can check.
Internet speed
Programming type
The size of the files (you probably need a lot of time to load for a
high volume file)
And another solution is to store the information you've previously received into the phone's memory(cache).

What is the best way to save images in Parse?

What am I trying to achieve: Based on some filters by the app user, I want to return a list with text and images.
How am I doing it: I have created a table in Parse and have added a column with object type as 'file'. I have put all the jpg/gif images into that column. (double-click, browse, select image from local computer).
The trouble I am having is, the list takes considerable time (~7 seconds) before it is displayed on my android app.
Is there a better way of handling image data within Parse or should I store images somewhere else (like Amazon S3)?
I am using standard queries for Parse in order to get data, nevertheless, am also checking if there is any code latency. Wanted to confirm if I am correctly handling the image data for back-end or not.
Is there a better way of handling image data within Parse or should I
store images somewhere else (like Amazon S3)?
If your images is not too much or you are using for example(five image) its better to save the into the Assets or Drawable Folder for loading.
and if i correctly knows about this problem, you need to use ProgressBar and one image, before loading the Images in Internet.
Caching images and displaying
Hope this helps.
I am using Parse to store images too, but it's not slow as you said. Since Parse is part of Facebook, I think their infrastructure is the same. There are possible issues:
Internet connection: Slow or on 3G?
Images: files are big?
Let me know which case you are in.
If you just display thumbnail images, I suggest you to process it before saving to Parse by writing Cloud function as describe on their blog. The you just need to use generated thumbnails on your listview/gridview

NetworkImageView. Save image in thumbnail [Server] / resize in client?

I'm trying to create a CRUD android application.
Now, when the List Activity is shown, it will display the items created along with a thumbnail of the original image.
What is the best practice for displaying a thumbnail in an Android application with Volley? Should I generate a thumbnail for the images uploaded or just re-size the image at the client side?
It's hard to come up with a general answer for this questions because it all depends on how many images you're trying to download and how important showing the thumbnails is.
I would personally generate the thumbnails on the server side as soon as they are uploaded by the user. Doing this has several advantages:
All your app has to do is request the thumbnail and render it, which is much simpler and less CPU-intensive than using Volley's ImageRequest.
Smaller images means less data usage. You definitely don't want your app to download a 10MB 25-megapixel image over a 3G connection just to shrink it to a 100x100 thumbnail that the user might not even care about.
The only drawback that I can think of is that you might have to generate multiple thumbnails, one for each screen size (e.g. one for hdpi screens and another for xxhdpi). This is slightly more expensive on the server side but might make your UI look much better.
Also, remember to cache thumbnails in your app's cache directory so you don't have to re-request them every single time you want to show them.

Design of mobile app and server dealing with different size of photos

I don't know this title is clearly reflect the question content. Please help rephrase if you think it is confusing. Thanks!
This is a generic question about some common architecture. I am working on a Android app that can take and share photo just like Instagram. And I have a backend web service powered by Django.
The issue I am facing is, in the app, I will need to show different resolution of image (for example, thumbnails for profile image, mid-resolution for previews, and full resolution for expanded image views.) I want to ask a common pattern about how to make this happen.
I have two proposals on doing this task, and not sure which way I should go:
1.When user upload photos from the mobile app, I can compress it locally and send 3 different sizes (low res thumbnails, mid res, and high res). So server side can store them and return them back in different cases. The Con of this approach that I can think about is it will drain more user's data usage because now user will need to send multiple images. It may also cause uploading take more time and higher impact in user experience.
2.When user upload photos from the mobile app, they only upload the original image. The server side logic will do the compression for each income image, and store them accordingly. The Con of this approach is server may need to carry a lot more workload. In this case, if user increases a lot, it may crash the server.
I am hoping to get some pointer on this issue, or any reference about this topic will be helpful!
Upload the full size image to the server and have the server do the heavy lifting. Create three version of the image (small medium and large) and store them on the server (or content delivery network). Create a database table to keep track of the image id for each image and its various versions.
With android you wont know how powerful the phone running your app is, never assume it can handle whatever image manipulation you need, also try and keep network I/O as low as possible.
Alan - Think of smart phones as relatively dumb terminals made for purpose of consuming content. Most of the business logic and heavy processing should me implemented on server side.
In terms of architecture, you are facing scalability problem. You cannot expand cpu/memory or storage of a device to any level you want. However you can scale your servers horizontally or vertically by adding more ram/cores/disks etc. You can put cluster on server and have a farm of servers if data increases to that level.
So its always advisable to just upload the original image without locally processing. Locally processing also drains battery besides other downside you mentioned.
Again you business logic or processing technique changes, you have to redeploy all apps. Where as on server side such deployments are very well in your control.
What i would do is a first resize in the mobile, just one, because you dont one to transfer 13Mpx picture and also you dont want in your server a picture 2 screens wide (this is the first thing instagram does). After that, upload the file, and have the server doing the rest of the stuff.
this avoid a lot of that usage
ensures that will work fine in any device (every one has different capabilities, so you cant trust them for heavy work)
You can change some decisions about settings or configurations, and all this is centralized, if you change any common behavior, you don't need all the devices to get the last version of the app.
About crashing the server, there is one first measure i would take:
Don't do any operation, like re-sizing or making copies of the image in the moment of the upload, you can choose one of this approaches:
Do it when there is a request for the file. this is, dont do it when the user sends it, but when somebody needs it.
Do it in a continuos backgorund process, like a cronjob running every minute, for instance.
or a combination of the two, there is a process in the background doing the stuff for all the pending images, but if somebody enters in the website and they need an image that is not yet generated, it is generate in that moment.

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

Categories

Resources