I want to download an image from the web server for every 1 second. Can some one tell me the best approach to achieve this. Currently, i am thinking to use Executer class but i am not sure whether that would be a better approach or not. Please help me.
to perform this you might need use asynctask. this is my idea, retrieve all the image url from the server,then manipulate the url. you can use library such as android smart android view to display the image from the server just by only providing the image url.
android smart android view:-
http://loopj.com/android-smart-image-view/
Related
I see some wallpaper apps on the market and they update the images daily or weekly. I wonder how they do that. I use picasso library but I cannot do that with picasso. Is there anyone can help?
One way to achieve what you want is you can make webservice/api to pass image url from the server and now anytime whatever image url that api will respond/contains that you can load in your ImageView. And that't it.
Note - You must have a knowledge of making webservice and calling them and handling the http request response in advance for this before applying this approach.
Thanks.
So i´m creating a app in Android which stores images in a external server. I want to know where is better to make the optimization of the image file, in server, or give the non-optimize image to local and then optimize inside the app. Im using mysql for store the images, but if its better to use sqlite server i will change it. Thanks.
The best thing to do here is create an application on your server exposed through an API with query parameters to specify image sizes + caching mechanism.
For example:
www.mywebsite.com/imageloader/file-identifier?width=50&height=50&format=png
then implement a caching mechanism take a look at (https://dev.mysql.com/doc/refman/5.1/en/ha-memcached.html) for mysql on the server for this image using these parameters so the application can quickly return this file each time and not require too much work from the application. This will allow you to request multiple images at specific sizes when you need them for example only as a thumbnail... Or a full Gallery image which can be something much larger.
Additionally you will want to use an Image Library and there are certainly quite a few for Android (to name a few):
Picasso from Square http://square.github.io/picasso/
Fresco from Facebook https://github.com/facebook/fresco
Ion from this Github https://github.com/koush/ion
These can all help you format your images and cache them locally and even downsize the images as necessary.
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 have an app that gets data from web api.
I am returning some info and image from web api. I have 2 options for image and these are:
Return image link(web address) and download it with async task.
Return image in base64 encoded string.
I would want to know which is faster and better idea?
Thanks.
I would say this depends on the way your application is workingand what it needs,
The data itself is the same, so just think what would fit your app better,
I'll give some examples:
If the web api returns many responses with the same image and different info, you might want to use another server so you could use caching systems / cdn and than better perform your app
If it would help you that the "info" will reach to the app before the image (so you could load it first), you should also use the first option, and when the async proccess ends display the image (just an example...)
If you want to spare computing resources from the api servers every time it is used (encoding the image to base64 ect..) you should also use the first option
If lets say, you want to make sure that all the data comes at-once and non of the above is relevent to you, maybe you would prefer the second option
If you want to avoid async requests or having multiple requests every time may be the second option is better for you too
So, its just up to what your app needs :)
Hope i helped
I need to load several thumbnails (the images on the server are full sized images, so I need to resize them in the app), and display them in a way that allows for the user to click on one (or more) and have some associated id be given back to the app for use in a larger context.
so, in pseudo code...
ImageObjArray ioa = loadImagesFromServer("http://server/listOfImages.php");// this returns
for(ImageObj io : ioa){
drawThumbnail(io); //io contains both a jpg and a reference id
}
//later when a user clicks on a thumbnail
clickHandler(){
passIdToBundle(this.refId);
}
So, I've never played with a webview before but I suspect it might be the best approach here, though I don't know how easy it is to send info back out of a webview to the larger app when the user clicks on a thumbnail. Or is there a more elegant approach?
All advice welcome.
Using a WebView would be the quickest way to implement this. Otherwise, you have to fetch each image and write them to the device in order to display them in a native Android widget. There are several ways to approach this, like: http://www.dreamincode.net/code/snippet4724.htm
You can use WebView.addJavascriptInterface to communicate with native code. A good example can be found in the WebViewDemo from the apps-for-android project on Google Code.
You might want to consider a framework like PhoneGap to help with the Java to JavaScript interface.