ahorn / android-rss Goto Github PK
View Code? Open in Web Editor NEWLightweight Android library to parse RSS 2.0 feeds.
Lightweight Android library to parse RSS 2.0 feeds.
I tried to put a feedburner URL like this one and it didn't work.
Is there a way to get around this?
I have to use a custom User-Agent string in the request to the server. One way of doing that (I think) would be to pass my own HttpClient to the constructor of RSSReader where I have set the correct user-agent beforehand. The problem is that I have to pass an RSSParser at the same time and I can't seem to use "new RSSParser(new RSSConfig())" from my own code as the RSSParser class is not public.
How about adding a constructor like this to RSSReader.java?
/**
* Instantiate a thread-safe HTTP client to retrieve RSS feeds. The injected
* {@link HttpClient} implementation must be thread-safe.
* Internal memory consumption and load performance can be tweaked with
* {@link RSSConfig}.
*
* @param httpclient thread-safe HTTP client implementation
* @param config RSS configuration
*/
public RSSReader(HttpClient httpclient, RSSConfig config) {
this(httpclient, new RSSParser(config));
}
Then it can be called like this:
String userAgent = "custom-user-agent";
AndroidHttpClient httpClient = AndroidHttpClient.newInstance(userAgent);
RSSConfig rssConfig = new RSSConfig(5, 5);
RSSReader reader = new RSSReader(httpClient, rssConfig);
I am sorry .. i dont know where to post this .. so making it a new issue.. Sorry for this ..
I am using ur library & it works fine for RSS. Now i need 2 support ATOM feed.
could u please suggest what modifications do i need 2 make to support ATOM.
will just modifying the parser code to support all ATOM tags will work. (i mean adding OR clauses ... example "item" or "entry" ..) will do the magic ?
Hi,
I was getting the NumberFormatException while loading the rss feed from [http://spectrum.ieee.org/rss/fulltext] as below:
Caused by: java.lang.NumberFormatException: Invalid int: ""
at java.lang.Integer.invalidInt(Integer.java:138)
at java.lang.Integer.parseInt(Integer.java:358)
at java.lang.Integer.parseInt(Integer.java:334)
at org.mcsoxford.rss.MediaAttributes.intValue(MediaAttributes.java:47)
at org.mcsoxford.rss.RSSHandler$7.set(RSSHandler.java:210)
at org.mcsoxford.rss.RSSHandler.startElement(RSSHandler.java:269)
at org.apache.harmony.xml.ExpatParser.startElement(ExpatParser.java:143)
at org.apache.harmony.xml.ExpatParser.appendBytes(Native Method)
at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:513)
at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:474)
at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:316)
at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:279)
at org.mcsoxford.rss.RSSParser.parse(RSSParser.java:96)
at org.mcsoxford.rss.RSSParser.parse(RSSParser.java:65)
at org.mcsoxford.rss.RSSReader.load(RSSReader.java:107)
Caused by an empty string. The only check done in intValue function is for a null string. Added check for empty string to return the default value for my local version.
if((value == null) || (value.isEmpty())) { return defaultValue; }
Regards
Nabarun
Add some kind of API that allows devs to add support for new tags. It can by adding setters to RSSHandler. I have to handle RSS feed where instead of pubDate
there is dc:date
, and there is no possibility to use that library.
Hi, I just want to try your library and it seems I'm not able to install it. It gives me error:
Error: Flag '--library' is not valid for 'update lib-project'.
I just today upgraded SDK Tools to revision 12. Maybe this is source of problem.
android -h update lib-project gives me:
Options:
-p --path The project's directory [required]
-t --target Target ID to set for the project
Thanks for help
It would be very helpful and time saving to add the proguard rules needed in order to add this library to a project.
The feed I am Reading uses the tag "entry" instead of "item". The name of tag is encoded in a private final static field in class RSSHandler. So I have changed the string in the source code.
It would be nice a way to set this tag name without modifying the original source code.
Thank you.
Hi,
I'm using your library to read many rss feeds at a time.
I noted strange dates in my articles and searching the code I noticed that:
/**
SimpleDateFormat is NON thread-safe so you can't declare as static
https://stackoverflow.com/questions/6840803/why-is-javas-simpledateformat-not-thread-safe
Thanks for your great work.
To avoid requests on orientation change, being able to Parcel this items would make things easier.
I can make the PR, but it's terrible to still work on a Eclipse project structure :(
It would be nice if you could add a feature to dump the whole XML to a string so that it can be stored as a file.
Tried to use your lib unfortunately got an error:
E/g.allatra.vest: Maybe bug 77342775, looking for Lorg/apache/http/conn/scheme/SchemeSocketFactory; 0x12e2c808[continuous;main space (region space)] defined in /data/app/org.allatra.vesti-6Ivn8VX5g-PnsnhK81HszA==/base.apk/0x7d2fdd40d7c0 with loader: dalvik.system.PathClassLoader/0x7d2f4ce29a50[hit:continuous;main space (region space)](/data/app/org.allatra.vesti-6Ivn8VX5g-PnsnhK81HszA==/base.apk/0x7d2fdd40d7c0);java.lang.BootClassLoader/0x7d2fdd373c30 in interface table for Lorg/apache/http/conn/ssl/SSLSocketFactory; 0x70398ba8[image;/system/framework/x86_64/boot-framework.art;+;0x7035e000] defined in /system/framework/framework.jar!classes3.dex/0x7d2fdd489140 ifcount=2 with loader BootClassLoader iface #0: org.apache.http.conn.scheme.SocketFactory iface #1: org.apache.http.conn.scheme.LayeredSocketFactory W/g.allatra.vest: Accessing hidden method Ljava/lang/Thread;->getUncaughtExceptionPreHandler()Ljava/lang/Thread$UncaughtExceptionHandler; (greylist,core-platform-api, reflection, allowed) E/AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-1 Process: org.allatra.vesti, PID: 8644 java.lang.IncompatibleClassChangeError: Class 'org.apache.http.conn.ssl.SSLSocketFactory' does not implement interface 'org.apache.http.conn.scheme.SchemeSocketFactory' in call to 'java.net.Socket org.apache.http.conn.scheme.SchemeSocketFactory.createSocket(org.apache.http.params.HttpParams)' (declaration of 'org.apache.http.impl.conn.DefaultClientConnectionOperator' appears in /data/app/org.allatra.vesti-6Ivn8VX5g-PnsnhK81HszA==/base.apk) at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:136) at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149) at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121) at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:561) at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:415) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732) at org.mcsoxford.rss.RSSReader.load(RSSReader.java:94) at org.allatra.vesti.rss.RssParser$fetchFeed$1.invokeSuspend(RssParser.kt:29) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:233) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594) at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:742) I/Process: Sending signal. PID: 8644 SIG: 9 Application terminated.
Hello.
I'm trying to parse a feed from my website, which is encoded in ISO-8859-1 and uses accented characters (which are very common in Italian language). The parser throw an exception and the application is crashing.
This is the URL of my feed: http://forum.wininizio.it/index.php/rss/blog/
Please, can you help me in order to get it to work?
Thanks for this great piece of code! :)
Hi,
I tried to use your library but I got the error on title.
Can you help me with it?
Thanks.
Hello,
I'm using this library and try to get enclosure from the RSS Feed like :
http://lesclesdedemain.lemonde.fr/screens/RSS/sw_getFeed.php?idTheme=HOME
or
http://www.gamergen.com/rss
But the return value is always null, any idea of which class I can edit to perform enclosure retrieving ?
Cheers.
Hi,
I am new to android development. How do I make use of the library in Android Studio? What should I be adding to the build file?
Hi ahorn, this is isn't an issue but I'm looking to manage in a polite way any eventual network disconnections in my app when using android-rss.
Can you recommend me how to catch and handle this kind of exception. I was trying to manage it in my code but that exception is not throwed directly from my code. The main idea is to prevent my app to break with a message error, and handle it whit a polite message to the user.
Thank you in advance,
Martin
Trying to compile with this library in my app on API level 25 and it's not working.
Error:(46, 13) Failed to resolve: org.apache.httpcomponents:httpclient:4.5
After examining some other help it seems like your library is using an old networking library that is not present in the latest versions of Android (and beyond).
Seems like the problem lies in the RSSReader
class right at the start.
public RSSFeed load(String uri) throws RSSReaderException {
HttpGet httpget = new HttpGet(uri);
With some slight tweaking of how the data is retrieved, it should be easy to replace this in the app without any other impact.
Unfortunately not much more information is given although it is caused by this line:
feed = reader.load(uri);
Hervé Piedvache wrote:
I would like to use your android-rss library which seems to give me exactly
what I want to do ... but i'ts my first Android development with external
class. I'm a little lost ... may be you will solve this in two seconds ...
I have just start a new project ... nothing inside for the moment ... and want
to start integrating android-rss ...
So I have followed your instructions to reference this lib with my project :
./android update project -p ~/workspace/FootcowBlog/ -l ~/sources/android-rss/
-t 8
Resolved location of library project to: /home/herve/sources/android-rss
Updated default.properties
Updated local.properties
File build.xml is too old and needs to be updated.
Updated file /home/herve/workspace/FootcowBlog/build.xml
Updated file /home/herve/workspace/FootcowBlog/proguard.cfg
Nothing special here ... except that I get a build.xml file (attached) and
Eclipse said : Default target help does not exist in this project ...
I have tried to defined a target ... default one uncommenting "-pre-build" and
replace "help" by this ... running but when I just copy the 3 examples line
you gave :
RSSReader reader = new RSSReader();
String uri = "http://feeds.bbci.co.uk/news/world/rss.xml";
RSSFeed feed = reader.load(uri);
RSSReader is not found ... and I can't see what to include anywhere to solve
this, I mean I'm sure there is import to do ... but after a build, I don't see
any class ...
Could you please give me an answer about this ...
Hi,
can you add support from gradle and publish as artifact on maven central?
you can follow this guide:
http://gmariotti.blogspot.it/2013/09/publish-aar-file-to-maven-central-with.html
The extension of README should be .md, otherwise github doens't render it as markdown.
Seems the parser doesn't work when building for/running on android 1.6. It doesn't error just doesn't fill fields. When I call load feed returns 0 items, is not null but zero length. If I change the target to 2.2 then the feed returns items. If I debug through the code the difference appears here in RSSHandler:
public void startElement(String nsURI, String localName, String qname, org.xml.sax.Attributes attributes)
qname is "" in the Android1.6 where in 2.2 its filled.
the default conection timeout and read timeout of HttpURLConnection is -1 which means the socket will always wait to read data and block the user thread forever if server not finish the connect,so the user thread seems to stop running.
to fix this bug may change "load" method of "RSSReader" like below:
......
private int readTimeout=30000;
private int connectTimeout=30000;
......
public RSSFeed load(String uri) throws RSSReaderException{
......
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setConnectTimeout(readTimeout);
conn.setReadTimeout(connectTimeout);
conn.connect();
......
}
Hi everybody
This is my rss and it won't work in this library
http://yazd.irib.ir/news/-/asset_publisher/Z10PWtuy88n7/rss
i would know why!
Thanks
All the classes package names are wrong - with an addition of words like "test,com.." or so.
I'm kind of new to android - I'm unable to import this..
You think it's just missing a file for eclipse to import??
Would love the help.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.