public String generateXML(String sessionID,String versionName,long installAge,RequestData data) throws RequestFailureException {
  XmlSerializer serializer=Xml.newSerializer();
  StringWriter writer=new StringWriter();
  try {
    serializer.setOutput(writer);
    serializer.startDocument("UTF-8",true);
    serializer.startTag(null,"request");
    serializer.attribute(null,"protocol","3.0");
    serializer.attribute(null,"version","Android-1.0.0.0");
    serializer.attribute(null,"ismachine","1");
    serializer.attribute(null,"requestid","{" + data.getRequestID() + "}");
    serializer.attribute(null,"sessionid","{" + sessionID + "}");
    serializer.attribute(null,"installsource",data.getInstallSource());
    appendExtraAttributes("request",serializer);
    serializer.startTag(null,"os");
    serializer.attribute(null,"platform","android");
    serializer.attribute(null,"version",Build.VERSION.RELEASE);
    serializer.attribute(null,"arch","arm");
    serializer.endTag(null,"os");
    serializer.startTag(null,"app");
    serializer.attribute(null,"brand",getBrand());
    serializer.attribute(null,"client",getClient());
    serializer.attribute(null,"appid",getAppId());
    serializer.attribute(null,"version",versionName);
    serializer.attribute(null,"nextversion","");
    serializer.attribute(null,"lang",getLanguage());
    serializer.attribute(null,"installage",String.valueOf(installAge));
    serializer.attribute(null,"ap",getAdditionalParameters());
    appendExtraAttributes("app",serializer);
    if (data.isSendInstallEvent()) {
      serializer.startTag(null,"event");
      serializer.attribute(null,"eventtype","2");
      serializer.attribute(null,"eventresult","1");
      serializer.endTag(null,"event");
    }
 else {
      serializer.startTag(null,"updatecheck");
      serializer.endTag(null,"updatecheck");
      serializer.startTag(null,"ping");
      serializer.attribute(null,"active","1");
      serializer.endTag(null,"ping");
    }
    serializer.endTag(null,"app");
    serializer.endTag(null,"request");
    serializer.endDocument();
  }
 catch (  IOException e) {
    throw new RequestFailureException("Caught an IOException creating the XML: ",e);
  }
catch (  IllegalArgumentException e) {
    throw new RequestFailureException("Caught an IllegalArgumentException creating the XML: ",e);
  }
catch (  IllegalStateException e) {
    throw new RequestFailureException("Caught an IllegalStateException creating the XML: ",e);
  }
  return writer.toString();
}

public String generateXML ( String sessionID , String versionName , long installAge , RequestData data ) throws RequestFailureException { XmlSerializer serializer = Xml . newSerializer ( ) ; StringWriter writer = new StringWriter ( ) ; try { serializer . setOutput ( writer ) ; serializer . startDocument ( "UTF-8" , true ) ; serializer . startTag ( null , "request" ) ; serializer . attribute ( null , "protocol" , "3.0" ) ; serializer . attribute ( null , "version" , "Android-1.0.0.0" ) ; serializer . attribute ( null , "ismachine" , "1" ) ; serializer . attribute ( null , "requestid" , "{" + data . getRequestID ( ) + "}" ) ; serializer . attribute ( null , "sessionid" , "{" + sessionID + "}" ) ; serializer . attribute ( null , "installsource" , data . getInstallSource ( ) ) ; appendExtraAttributes ( "request" , serializer ) ; serializer . startTag ( null , "os" ) ; serializer . attribute ( null , "platform" , "android" ) ; serializer . attribute ( null , "version" , Build . VERSION . RELEASE ) ; serializer . attribute ( null , "arch" , "arm" ) ; serializer . endTag ( null , "os" ) ; serializer . startTag ( null , "app" ) ; serializer . attribute ( null , "brand" , getBrand ( ) ) ; serializer . attribute ( null , "client" , getClient ( ) ) ; serializer . attribute ( null , "appid" , getAppId ( ) ) ; serializer . attribute ( null , "version" , versionName ) ; serializer . attribute ( null , "nextversion" , "" ) ; serializer . attribute ( null , "lang" , getLanguage ( ) ) ; serializer . attribute ( null , "installage" , String . valueOf ( installAge ) ) ; serializer . attribute ( null , "ap" , getAdditionalParameters ( ) ) ; appendExtraAttributes ( "app" , serializer ) ; if ( data . isSendInstallEvent ( ) ) { serializer . startTag ( null , "event" ) ; serializer . attribute ( null , "eventtype" , "2" ) ; serializer . attribute ( null , "eventresult" , "1" ) ; serializer . endTag ( null , "event" ) ; } else { serializer . startTag ( null , "updatecheck" ) ; serializer . endTag ( null , "updatecheck" ) ; serializer . startTag ( null , "ping" ) ; serializer . attribute ( null , "active" , "1" ) ; serializer . endTag ( null , "ping" ) ; } serializer . endTag ( null , "app" ) ; serializer . endTag ( null , "request" ) ; serializer . endDocument ( ) ; } catch ( IOException e ) { throw new RequestFailureException ( "Caught an IOException creating the XML: " , e ) ; } catch ( IllegalArgumentException e ) { throw new RequestFailureException ( "Caught an IllegalArgumentException creating the XML: " , e ) ; } catch ( IllegalStateException e ) { throw new RequestFailureException ( "Caught an IllegalStateException creating the XML: " , e ) ; } return writer . toString ( ) ; }
generates the xml for the current request . follows the format laid out at http : / / code . google . com / p / omaha / wiki / serverprotocol with some additional dummy values supplied .
