I am using a web service that returns JSON in response. I want to parse the response and crate a list of object. I Don't know how to show the parsed data in UI in android. where user can select one item form the list (i.e. Dubai mall or dubai media city or dubai festival).
public class MyLocation extends MapActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location);
initButtons();
initMapView();
initMyLocation();
jObject=getJSONFile("http://loyaltier.com/app/mobile/code/places/Maps.php");
}
private JSONObject getJSONFile(String URL) {
JSONObject jObject=null;
HttpGet httpGet=new HttpGet(URL); //http://loyaltier.com/app/mobile/code/places/Maps.php
HttpClient httpClient=new DefaultHttpClient();
HttpResponse httpResponse;
StringBuilder stringBuilder=new StringBuilder();
try{
httpResponse=httpClient.execute(httpGet);
HttpEntity httpEntity=httpResponse.getEntity();
InputStream inputStream=httpEntity.getContent();
int c;
while((c=inputStream.read())!=-1){
stringBuilder.append((char)c);
}
}catch(Exception e){
e.printStackTrace();
}
try{
jObject=new JSONObject(stringBuilder.toString());
}catch(JSONException e){
Log.e("Log_tags ", "Error parsing data "+e.toString());
}
return jObject;
}
}