Rahul, This should solve your problem if you get stuck let me know. I just wrote this specifically to address your problem and for my own reference http://www.josecgomez.com/2010/04/30/android-accessing-restfull-web-services-using-json/
Sincerely Jose C Gomez http://www.josecgomez.com On Fri, Apr 30, 2010 at 8:16 AM, Rahul <rahulvarma.kalidindi0...@gmail.com>wrote: > I have done the following. But still i cant get the result... Can > anyone help me determine what the error is...Plzzzz help me out... > > public class AlertsAdd { > public ArrayList<JSONObject> retrieveJSONArray(String urlString) { > String result = queryRESTurl(urlString); > ArrayList<JSONObject> ALERTS = new ArrayList<JSONObject>(); > if (result != null) { > > try { > JSONObject json = new JSONObject(result); > Log.i("Info",json.toString()); > > JSONObject alertsObject = json.getJSONObject("alertid"); > ALERTS.add(alertsObject); > > return ALERTS; > } catch (JSONException e) { > Log.e("JSON", "There was an error parsing the JSON", > e); > } > } > JSONObject myObject = new JSONObject(); > try { > myObject.put("Alert Id",myObject.getJSONArray("alertid")); > ALERTS.add(myObject); > } catch (JSONException e1) { > Log.e("JSON", "There was an error creating the JSONObject", > e1); > } > return ALERTS; > } > > > public class AlertsAdapter extends ArrayAdapter<JSONObject> { > public AlertsAdapter(Activity activity, List<JSONObject> alerts) { > super(activity, 0, alerts); > } > @Override > public View getView(int position, View convertView, ViewGroup > parent) { > Activity activity = (Activity) getContext(); > LayoutInflater inflater = activity.getLayoutInflater(); > View rowView = inflater.inflate(R.layout.list_text, null); > JSONObject imageAndText = getItem(position); > TextView textView = (TextView) > rowView.findViewById(R.id.last_build_stat); > try { > > textView.setText((String)imageAndText.get("alertid")); > } catch (JSONException e) { > textView.setText("JSON Exception"); > } > > return rowView; > } > > -- > 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+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en