Android™
Android™
Demonstrate HttpRequest.RemoveAllParams
Demonstrates the effect of calling HttpRequest.RemoveAllParams.Chilkat Android™ Downloads
// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;
import android.app.Activity;
import com.chilkatsoft.*;
import android.widget.TextView;
import android.os.Bundle;
public class SimpleActivity extends Activity {
private static final String TAG = "Chilkat";
// Called when the activity is first created.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CkHttpRequest req = new CkHttpRequest();
req.put_HttpVerb("POST");
req.put_Path("/test123");
req.put_ContentType("application/x-www-form-urlencoded");
req.AddParam("paramA","AAA");
req.AddParam("paramB","BBB");
req.AddParam("paramC","CCC");
Log.i(TAG, req.generateRequestText());
Log.i(TAG, "---------------");
// Generates:
// POST /test123 HTTP/1.1
// Content-Type: application/x-www-form-urlencoded
// Host: domain
// Content-Length: 32
//
// paramA=AAA¶mB=BBB¶mC=CCC
//
// If we call RemoveAllParams, and then add some additional params,
// then the original params are gone, and only the new params exist.
req.RemoveAllParams();
req.AddParam("paramD","DDD");
req.AddParam("paramE","EEE");
req.AddParam("paramF","FFF");
Log.i(TAG, req.generateRequestText());
Log.i(TAG, "---------------");
// Generates:
// POST /test123 HTTP/1.1
// Content-Type: application/x-www-form-urlencoded
// Host: domain
// Content-Length: 32
//
// paramD=DDD¶mE=EEE¶mF=FFF
}
static {
System.loadLibrary("chilkat");
// Note: If the incorrect library name is passed to System.loadLibrary,
// then you will see the following error message at application startup:
//"The application <your-application-name> has stopped unexpectedly. Please try again."
}
}