Android™
Android™
Load MIME from XML
See more MIME Examples
Demonstrates the Chilkat Mime.LoadXml method, which reconstructs a MIME tree from Chilkat's MIME XML. The only argument is the XML string.
Background: Chilkat can represent a MIME tree as XML — headers as elements, parameters as attributes — which is convenient for inspecting or editing structure with XML tools. This is the inverse of
GetXml: it rebuilds the full MIME object from that representation. Invalid XML leaves the current object unchanged.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);
boolean success = false;
// Demonstrates the Mime.LoadXml method, which reconstructs a MIME tree from Chilkat's MIME XML.
// The only argument is the XML string.
CkMime mime = new CkMime();
// Chilkat MIME XML (as produced by GetXml).
String xmlText = "<mime><contentType>text/plain</contentType><body>Hello.</body></mime>";
success = mime.LoadXml(xmlText);
if (success == false) {
Log.i(TAG, mime.lastErrorText());
return;
}
Log.i(TAG, "Content-Type: " + mime.contentType());
}
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."
}
}