Display image using a RSS feed - android

I have an application in which use a RSS feed reader. My problem is that I don't know what is the best way to display an image. The closer I could get was to pull the image description (). I know I could parse this String by myself and get the image url, but I was wondering if there is a more elegant way to solve this issue. I tried using the SAX and the DOM classes, but I couldn't figure it out.

Best way to DISPLAY the image? I'm not sure if that's actually what you're asking, but just use an ImageView. Use an AsyncTask to download the image in the background, and then create a new Drawable from that downloaded image (might even want to cache it to storage) and set that as the source for the ImageView.

there is a library for downloading and caching images in background from the URL
https://github.com/koush/UrlImageViewHelperSample
=)

Are you asking how to get the image URL from the XML RSS feed? There's nothing built into the SDK that's going to help you parse the XML, other than SAX or DOM which you have already noted. There is a learning curve to those, but they are reasonable approaches.
There's a project called ROME that is an API for robustly parsing all sorts of feeds, including RSS. You could import this library into your android app. Note that this library has other dependencies, so you'd have to import them also. I haven't done it personally, but I have heard of people using ROME in Android apps, so it's doable.
Or more simply, if you just want the image URL and you don't need a complete feed parser, you can use java.util.regex to parse out the fields you want.
If you are asking how to display the image after you have the URL, kcoppock's answer explains it.

Related

What is the common way to get images from urls in android application

I see a lot of android applications just look like html pages, containing many images here and there. But I don't know usually how these applications get their images to render. Do they get images through url. I found some posts on the internet suggested to use AsyncTask to download image through a HttpURLConnection . But I think AsyncTask is a little bit too complicated which involves too much code. Can anyone recommend me a simple,brief and may be also standard approach to get images to render in android applications?Any help is much appreciated!
Use an image loading library, like Glide (https://github.com/bumptech/glide), Picasso (http://square.github.io/picasso/) or Fresco (https://github.com/facebook/fresco) among others.
I will suggest using glide as it is lightweight and easy to use.
Glide
And also has its own many features.

JSON image to sqlite Android programming

I am new to Android Programming and would like to ask about JSON/sqlite. I have already parsed JSON text and store it in sqlite and then displayed the data in a listview in my app. However, I didn't parse the images in my JSON file (started with the easy part first). Now I have to do the image parsing and I have looked through many websites but still feel too confused about how to do it.
In the following link
http://www.androidbegin.com/tutorial/android-json-parse-images-and-texts-tutorial/
I have looked at how they do the image parsing but they're caching the images while I have to store the data into DB. In the link there is ImageLoader.java, MemoryCache.java, FileCachee.java,and Utils.java; these classes made me even more confused, do I need all of these for the images?
Can anyone please guide me like what steps I should follow? which classes of these do I need and which are not necessary?Or any kind of help.
Thank you in advance
To read in a single image, no you don't need all that. All you need is to read in an array of bytes (the contents of the file) and turn that into a Bitmap object. What all that is useful for is to hold lots of images at once- to make sure you don't use up too much RAM (MemoryCache), request them from the network more than once (FileChace), and to manage all of those (ImageLoader). So if you want to download lots of images its useful. For a single one its overkill.

9-patch images in Android WebView

Do 9-patch images work inside an Android WebView? I haven't found anything that definitively answers it one way or another. I know there's a project that uses Javascript to mimic it on the web (https://github.com/chrislondon/9-Patch-Image-for-Websites), so I figure to use that as a workable alternative but wondered if anyone else had ideas.
I think it is feasible and there are several ways that we could have a try.
Do it in js/css. Just as you mentioned, there are several js plugin that support parsing 9patch. And css3 also has a new feature named border-image, which could achieve the same result.
Do it in android. If it is only used in android, we can use WebView.addJavascriptInterface() and enable js to invoke android code. When javascript want a image, it send the image uri and desired size of the image to android. Android try to load the image and use NinePatchDrawable to parse it. Convert it to a bitmap and return back.

Android best way to retrieve images and view them from external source

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

xml parsing with no browser use

I have read the example for Rss Parsing from the ibm site.(http://www.ibm.com/developerworks/opensource/library/x-android/).
In this example,the rss are shown in a listview and then,if you press one announcement you can see it in the web browser of the device.How could i see them in the app,with no use of the device browser?
Thanks a lot
Create a layout with a WebView then load the URL from each "announcement" using WebView.loadUrl.
I'm a little confused but you seem to have answered your own question.
You say you don't want to use the web browser on the device but the example in your question doesn't use the browser. It does exactly what you're asking for.
The idea is that you download the html from the website and then use the parser to break it up into separate "announcements" and store them in list view items in your program.
I have done a bit of this type of thing myself in android. I used jsoup java library, which makes breaking the html into the bits you want to display really easy.
If you want some more help I can give you an example of an app I made that pulls movie times from google.com/movies as an example. here are links to the classes where I did the html download and parse:
ScreenScraper.java
HtmlParser.java

Categories

Resources