Thanks Megha..thats really nice of you...Yeah its working fine now
On Aug 23, 2:05 am, "Megha Joshi" <[EMAIL PROTECTED]> wrote:
> You were on the right track in porting your code...I updated the rest of
> your code to work with the new Http library...hope this helps!
>
> HttpClient client = new DefaultHttpClient();
> HttpGet get = new
> HttpGet("http://www.biocol.org/json/fetch/lsid/urn:lsid:biocol.org:
> col:15670");
> try {
>
> HttpResponse httpResponse = client.execute(get);
> String res="";
> if(httpResponse.getStatusLine().getStatusCode()!=404){
> res= EntityUtils.toString(httpResponse.getEntity());
> //
>
> String temp = res.substring(9);
> temp = temp.replace(")", "");
> JSONArray jarray = new JSONArray(temp);
> int i=0;
> String key="";
> JSONObject objs = new JSONObject();
> objs = jarray.getJSONObject(i);
> key=objs.getString("size");
> uname.setText(temp);
> }else
>
> uname.setText("nothing found");
> }
> catch (Exception e) {
> //Log.e("Error:",e.getMessage());
> uname.setText("fault: "+e.getLocalizedMessage());
> }
> finally {
> get.abort();
> get=null;
> }
>
> On Fri, Aug 22, 2008 at 12:47 AM, Baran <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I have this code that was running successfully on m5 SDK. Now I need
> > to port the same to SDK 0.9.
>
> > Till now I have successfully called the web service, but now sure how
> > to proceed further...the codes are as below:
>
> > On SDK m5
> > HttpClient client = new HttpClient();
> > GetMethod get = new GetMethod("http://www.biocol.org/json/
> > fetch/lsid/urn:lsid:biocol.org:col:15670<http://www.biocol.org/json/fetch/lsid/urn:lsid:biocol.org:col:15670>
> > ");
> > try {
> > int status = client.executeMethod(get);
> > String res="";
> > if(status!=404){
> > res=get.getResponseBodyAsString(); //
> > uname.setText("m here"+status+res);
> > String temp = res.substring(9);
> > temp = temp.replace(")", "");
> > JSONArray jarray = new JSONArray(temp);
> > int i=0;
> > String key="";
> > JSONObject objs = new JSONObject();
> > objs = jarray.getJSONObject(i);
> > key=objs.getString("size");
> > uname.setText(temp);
> > }else
>
> > uname.setText("nothing found");
> > }
> > catch (Exception e) {
> > //Log.e("Error:",e.getMessage());
> > uname.setText("fault: "+e.getLocalizedMessage());
> > }
> > finally {
> > get.releaseConnection();
> > get=null;
> > }
>
> > And on SDK 0.9
>
> > DefaultHttpClient client= new DefaultHttpClient();
>
> > HttpGet get = new HttpGet("http://www.biocol.org/json/
> > fetch/lsid/urn:lsid:biocol.org:col:15670<http://www.biocol.org/json/fetch/lsid/urn:lsid:biocol.org:col:15670>
> > ");
> > HttpResponse resp;
>
> > resp = client.execute(get);
>
> > I am not sure about where they have moved the API methods and how to
> > retrieve the output as string so that I can parse it using JSON...
>
> > Any help would be great
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new Android 0.9 SDK beta!
http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---