Android: Get data from server

Manoj Fegde picture Manoj Fegde · Mar 22, 2013 · Viewed 8.8k times · Source

I want to develop an application. In which user enter a URL at run time. The XML is placed on server. So how to hit or get the data of that XML, so that i can parse the data and use that. The parsing i know. But how to get data directly i dont know.

So please suggest me how to hit url and get data with out web service.

Answer

Raghunandan picture Raghunandan · Mar 22, 2013

In general

To make a request to the server, you can use a Asynctask or service.

For long running background operations use service.

An alternative to Asynctask is Robospice. https://www.google.co.in/search?q=robospice&oq=robospice&aqs=chrome.0.57j59l2j60j62l2.2501&sourceid=chrome&ie=UTF-8.

Making a soap request. http://www.youtube.com/watch?v=v9EowBVgwSo.

Sample code with screen shot at To use the tutorial in android 4.0.3 if had to work with AsynxTasc but i still dont work?.

Make a http request and get the response.

http://www.androidhive.info/2011/10/android-making-http-requests/

http://www.vogella.com/articles/AndroidNetworking/article.html.

If your respone is xml parse the xml file

http://www.mkyong.com/java/how-to-read-xml-file-in-java-dom-parser/. Parse using domparser.

http://www.mkyong.com/java/how-to-read-xml-file-in-java-sax-parser/. Parse using sax parser.