i need some real good Tutorials on using Android Web Services. PLease Help
Asked
Active
Viewed 598 times
0
-
If you want code then i can provide you.It seems that you want to learn how to fetch data from webservice in program – Tofeeq Ahmad May 10 '11 at 04:58
-
yes sure Tofeeq you can also provide me some code that could help me. actually i am trying to work on web services. i have a web service with login aand register methods . now in my android app how can i get to those login and register methods. pelase demonstrate... – Shah May 10 '11 at 05:05
1 Answers
1
String str="Webservice Url"
URL url=new URL(str);
URLConnection urlc=url.openConnection();
BufferedReader bfr=new BufferedReader(new InputStreamReader(urlc.getInputStream()));
String line;
while((line=bfr.readLine())!=null)
{
JSONArray jsa=new JSONArray(line);
for(int i=0;i<jsa.length();i++)
{
JSONObject jo=(JSONObject)jsa.get(i);
dispensary_id.add(jo.getString("dispensary_id"));
title.add(jo.getString("dispensary_name"));
image.add(jo.getString("review"));
distance.add(jo.getString("distance"));
if(jo.getString("image").equalsIgnoreCase("noimage.png"))
{
online_image.add(DispensaryConstant.noImageConstant);
}
else
{
online_image.add(jo.getString("image"));
}
}
}
}
catch(MalformedURLException e)
{
e.printStackTrace();
}
catch(IOException e)
{
e.printStackTrace();
}
catch(JSONException e1)
{
e1.printStackTrace();
}
handler.sendEmptyMessage(0);
}
It will code id you have Json data and if you have xml data you have to use other way
Tofeeq Ahmad
- 11,785
- 4
- 59
- 86