Android: Get data from server
Asked Answered
T

2

1

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.

Temperance answered 22/3, 2013 at 8:40 Comment(1)
have a edit text to allow user to enter url. get the url from edittext and make a http request. get the response parse and display the same.Disepalous
D
2

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.

Disepalous answered 22/3, 2013 at 8:51 Comment(0)
S
0

Use Web services like JSON,SOAP

I prefer JSON

JSON

How to create a JSON response:

Android includes JSON classes such as JSONArray, JSONObject that can be used to interpret the response the Web Service will return. See more at: Link

Stinker answered 22/3, 2013 at 8:43 Comment(3)
JSON is a webservice, who said it?Decrescendo
@Nirav Ranpara : I want to hit URL and copy the content in SD card with out the help of web service. So please suggest any method which can directly hit URL.Temperance
#15517747Disepalous

© 2022 - 2024 — McMap. All rights reserved.