http://www.androidsnippets.com/grab-a-url-source-with-progressdialog-and-asynctask
On Jan 31, 3:24 pm, aashutosh <aashutosh.andr...@gmail.com> wrote:
> Hello,
>
> How can i use Asynctask for the following code:
>
> public static String getXML() {
>
> String line = null;
>
> DefaultHttpClient httpClient = new DefaultHttpClient();
> HttpPost httpPost = new HttpPost("http://someurl/index.xml");
> try {
> HttpResponse httpResponse = httpClient.execute(httpPost);
> HttpEntity httpEntity = httpResponse.getEntity();
> line = EntityUtils.toString(httpEntity);
>
> } catch (UnsupportedEncodingException e) {
> line = "<results status=\"error\"><msg>Can't connect to server</
> msg></results>";
> } catch (MalformedURLException e) {
> line = "<results status=\"error\"><msg>Can't connect to server</
> msg></results>";
> } catch (IOException e) {
> line = "<results status=\"error\"><msg>Can't connect to server</
> msg></results>";
> }
>
> return line;
>
> }
>
> this basicaly gets an xml from the website
>
> Thanks in advance
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
No comments:
Post a Comment