image - send request using json in android -


possible duplicate:
send requst json java server in android

now working in gallery project. images on server database.using json want send request , response server, in server side using java.when images changed in database,gallery images must changed dynamically.how use json purpose,please me

package com.devstream.http;       import org.json.jsonexception;     import org.json.jsonobject;     import android.app.activity;     import android.os.bundle;     import android.util.log;      public class mainactivity extends activity {      private static final string tag = "mainactivity";      private static final string url = "http://www.yourdomain.com:80";       @override   public void oncreate(bundle savedinstancestate) {       super.oncreate(savedinstancestate);       setcontentview(r.layout.main);        // json object hold information, sent server       jsonobject jsonobjsend = new jsonobject();        try {        // add key/value pairs        jsonobjsend.put("key_1", "value_1");        jsonobjsend.put("key_2", "value_2");         // add nested jsonobject (e.g. header information)        jsonobject header = new jsonobject();        header.put("devicetype","android"); // device type        header.put("deviceversion","2.0"); // device os version        header.put("language", "es-es"); // language of android client        jsonobjsend.put("header", header);         // output json object we're sending logcat:        log.i(tag, jsonobjsend.tostring(2));        } catch (jsonexception e) {        e.printstacktrace();       }        // send httppostrequest , receive jsonobject in return       jsonobject jsonobjrecv = httpclient.sendhttppost(url, jsonobjsend);        /*        *  here on whatever want jsonobject, e.g.        *  1) value key: jsonobjrecv.get("key");        *  2) nested jsonobject: jsonobjrecv.getjsonobject("key")        *  3) nested jsonarray: jsonobjrecv.getjsonarray("key")        */        }     } 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -