HttpPost Iphone Versus Android
<p>1)On Iphone,</p>

<pre><code>- (void) postData:(NSMutableData *)_body withAction:(NSString *)_action binary:(BOOL)_binary
{
    [self stopProcess];



    binary = _binary;

    NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
    NSString *url = [NSString stringWithFormat:API_FORMAT, APP_SERVER, _action, [self getSession]];
    if (debug_switch) {
    NSLog(@"The action is %@", _action);
        NSLog(@"The accessing server API call Datafeed is %@", url);}
    [request setURL:[NSURL URLWithString:url]];
    [request setHTTPMethod:@"POST"];


    //TRACE(@"url: %@", url);

    if(_body != nil)
    {
        NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
        [request addValue:contentType forHTTPHeaderField: @"Content-Type"];
        [request setHTTPBody:_body];
    }

    //con = [NSURLConnection connectionWithRequest:request delegate:self];

    if(con != nil) {
        [con release];
    }
    con = [[NSURLConnection alloc] initWithRequest:request delegate:self];

    if (con) 
    {
        dataDict = nil;
        loading = YES;
        if(receivedData == nil) {
            receivedData = [[NSMutableData data] retain];
        }
        [receivedData setLength:0];
    }

}

static NSString *boundary = @"---------------------------147378274664144922";

@implementation DataFeed

BOOL connectable = NO;

///////////////////////////////

- (NSMutableData *) initContentBody
{
    NSMutableData *body = [NSMutableData data];
    [body appendData:[self addFormData:@"uid" withString:[[UIDevice currentDevice] uniqueIdentifier]]];
    return body;
}


//////////////////////////

- (NSData *) addFormBoundary
{
    return [[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding];
}

//////////////////////////////////////////


- (NSData *) addFormData:(NSString *)_name withInt:(int)_value
{
    return [self addFormData:_name withString:[[NSNumber numberWithInt:_value] stringValue]];
}


- (NSData *) addFormData:(NSString *)_name withFloat:(float)_value
{
    return [self addFormData:_name withString:[[NSNumber numberWithFloat:_value] stringValue]];
}


- (NSData *) addFormData:(NSString *)_name withString:(NSString *)_value
{
    NSMutableData *body = [NSMutableData data];
    [body appendData:[self addFormBoundary]];
    [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\";\r\n\r\n%@", _name, _value] dataUsingEncoding:NSUTF8StringEncoding]];    
    return body;
}

- (NSData *) addFormData:(NSString *)_name filename:(NSString *)_filename withData:(NSData *)_data
{
    NSMutableData *body = [NSMutableData data];
    [body appendData:[self addFormBoundary]];
    [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n", _name, _filename] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[[NSString stringWithString:@"Content-Type: application/zip\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; 
    [body appendData:[[NSString stringWithString:@"Content-Transfer-Encoding: binary\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:_data];    
    return body;
}
</code></pre>

<p>2)On Android, </p>

<pre><code>public void executeHttpPost() throws Exception {
    String address = "";
    HttpClient client = new DefaultHttpClient();
    HttpPost post = new HttpPost(address);

    List&lt;NameValuePair&gt; pairs = new ArrayList&lt;NameValuePair&gt;();
    pairs.add(new BasicNameValuePair("key1", "value1"));
    pairs.add(new BasicNameValuePair("key2", "value2"));
    post.setEntity(new UrlEncodedFormEntity(pairs));

    HttpResponse response = client.execute(post);

}
</code></pre>

<p><em><strong>The question, on body data of the android can it set to non json format, key-value pair?  as you can see on iphone,  body can be any parameters, doesn't have to be key value pair.can you give an example on android where the post data can be non-json format?</em></strong></p>
