I’m trying to get an xml feed from a website, nothing really special.
My problem is, when I’m trying to get my feed from my Android application, I’m automatically redirected to the mobile version of the website at the home page. This mean that the feed I get is the HTML page of the mobile website, not the xml file expected.
I tried to open the feed this way :
URL feedUrl = new URL(address);
Inputstream iStream = feedURL.openStream();
//or
Inputstream iStream = (InputStream)feedURL.getContent();
So… Is there anyway other way to do it? Anyway to avoid this redirection? I have absolutely no control over the website…
Thanks everyone!
What is probably happening is that the URL connection attaches a default user agent header to the HTTP request. The mobile web site receives this and redirects you to the mobile web site. I believe that it won’t be possible to change this behaviour with Android’s version of URL class.
A solution would be to use HttpClient, which you should be doing already anyhow.