Send JSON object via HttpPost method

by Alok Kulkarni » Tue, 08 Sep 2009 21:19:18 GMT

Sponsored Links
 Any answers ??


Send JSON object via HttpPost method

by Wayne Wenthin » Wed, 09 Sep 2009 05:39:03 GMT

 A snippet for what I do...
public HttpResponse updateGirl(String url, Pawn girl, int pawnID) {
HttpClient httpclient = new DefaultHttpClient();
HttpPut httpput = new HttpPut(url);

// Execute the request

try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(
nameValuePairs.add(new BasicNameValuePair("id", Integer
......  Many nameValuePairs later.....

httpput.setEntity(new UrlEncodedFormEntity(nameValuePairs,
 HttpResponse response = httpclient.execute(httpput);
return response;

} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
// e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
return null;


Hope that helps.   I struggled with it for a couple of weeks before I found
a site that had a good source.

Writing code is one of few things
that teaches me I don't know everything.


Sponsored Links

Send JSON object via HttpPost method

by Alok Kulkarni » Wed, 09 Sep 2009 16:44:42 GMT

 ey Wayne, thanks a lot..
I have also got a solution parallely which i would like to post

URL url = new URL(serverURL);

// open the conncetion
HttpURLConnection connection =

// Let the run-time system (RTS) know that we want input.
// Let the RTS know that we want to do output
// No caching, we want the real thing
// set the content type property

// set request method
// create the post body to send
String content = credDevPair.toString();
Log.i("Request ====....... ",content);
DataOutputStream printout = new DataOutputStream (
connection.getOutputStream () );

// send the data
String output =
Log.i("Response 1....... ",output);
// A Simple JSONObject Creation
JSONObject json=new JSONObject(output);


// A Simple JSONObject Parsing
JSONArray nameArray=json.names();
JSONArray valArray=json.toJSONArray(nameArray);
for(int i=0; i<valArray.length() ;i++)


//BufferedReader input = new BufferedReader ( new
InputStreamReader(connection.getInputStream()) );

}catch (ClientProtocolException e) {
// TODO Auto-generated catch block
}catch (IOException e) {
// TODO Auto-generated catch block

}catch(Exception ex)


private static String convertStreamToString(InputStream is) {
* To convert the InputStream to String we use the
* method. We iterate until the BufferedReader return null which
* there's no more data to read. Each line will appended to a
* and returned as String.
BufferedReader reader = new BufferedReader(new
StringBuilder sb = new StringBuilder();

String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
} catch (IOException e) {
} finally {
try {
} catch (IOException e) {

return sb.toString();

On Wed, Sep 9, 2009 at 3:08 AM, Wayn

Send JSON object via HttpPost method

by Wayne Wenthin » Thu, 10 Sep 2009 08:58:06 GMT

 ep that is what I vaguely based mine on.   I recognize the Praeda line.   I
had to modify mine because I was not sending back an array of json objects
but a specific one that I handle based on the ID on the backend with ruby.

On Wed, Sep 9, 2009 at 1:43 AM, Alok Kulkarni <> wrote:

Writing code is one of few things
that teaches me I don't know everything.


Send JSON object via HttpPost method

by Alok Kulkarni » Thu, 10 Sep 2009 13:28:31 GMT

 k.. ya i had taken that code part from the forum itself. :)

On Thu, Sep 10, 2009 at 6:27 AM, Wayne Wenthin <> wrote:


Other Threads

1. OpenMax-Bellagio integration in opencore

Hi All,

I am integrating the bellagio omx with opencore framework. I have enabled
the "HARDWARE_OMX" to include the vendor omx core.
I have included the libomxil and compilation is done.
On board omx test application are working fine. While playing with android
video player OMX_Init is called and all the components are registered in the
PV framework. It is failing in:

E/LIBOMXIL( 1750): In compMessageHandlerFunction
E/LIBOMXIL( 1750): In omx_videodec_component_MessageHandler
E/LIBOMXIL( 1750): FFMpeg Library/codec iniited
E/LIBOMXIL( 1750):
E/LIBOMXIL( 1750):  codec other than mpeg4 and avc(h264) is not supported --
codec not found
D/dalvikvm( 1586): GC freed 97 objects / 3984 bytes in 167ms
W/KeyCharacterMap( 1678): No keyboard for id 0

I have observed that the "omx_videodec_component_Constructor" is not called.
As per "Figure 2: OMX component instantiation through OMX_GetHandle"
in "OpenMax Call Sequences" document OMX_Handle() should be called before

Do I need to modify the Bellagio core/components?

Thanks in advance



2. How to re-install & sign android built-in applications covers building apps with the sdk?  Thats new.

I think he's looking for info on changing package names so that he can
replace the default apps. (I don't have that info handy, sorry..)


3. G1 VS. iPhone

4. UserSpace does not comeup with L2C enabling in Kernel

5. How to switch from Activity to ListActivity ?

6. MotionEvent & its historical values

7. android:manageSpaceActivity ?