开发者_开发百科
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this questioni need some real good Tutorials on using Android Web Services. PLease Help
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
精彩评论