I have a problem, I have an own attachment handler with the following code:
Quote:
public final class RoamingAttachmentHandler implements AttachmentHandler {
public static final long RAH_ID = 0x7651702a598f81a5L;
public RoamingAttachmentHandler(){
AttachmentHandlerManager.getInstance().addAttachme ntHandler(this);
}
//Returns an instance of the running FolderListenerApp.
public static RoamingAttachmentHandler waitForSingleton(){
//Ensure this is a singleton instance.
System.out.println("start attaching...");
//Open the RuntimeStore.
RuntimeStore store = RuntimeStore.getRuntimeStore();
//Obtain the reference of FolderListenerApp.
Object obj = store.get(RAH_ID);
//If obj is null, there is no current reference
//to FolderListenerApp. Start a new instance
// of FolderListenerApp if one is not running.
if (obj == null){
System.out.println("done");
//Store a reference to this instance in the RuntimeStore.
store.put(RAH_ID, new RoamingAttachmentHandler());
return (RoamingAttachmentHandler)store.get(RAH_ID);
}
else{
System.out.println("it still is");
return (RoamingAttachmentHandler)obj;
}
}
public static void unregister(){
//Open the RuntimeStore.
RuntimeStore store = RuntimeStore.getRuntimeStore();
//Obtain the reference of FolderListenerApp.
Object obj = store.get(RAH_ID);
if (obj != null)
AttachmentHandlerManager.getInstance().removeAttac hmentHandler((AttachmentHandler) obj);
}
public boolean supports(String string) {
System.out.println("ich werde gefragt: " + string);
return string.indexOf("x-mtravel-roaming") > -1 || string.indexOf("roaming.mdata") > -1;
}
public String menuString() {
return "Roamingpreise aktualisieren";
}
public void run(Message message, SupportedAttachmentPart supportedAttachmentPart) {
System.out.println("i'm handling...");
if(supportedAttachmentPart.hasMore()){
System.out.println("there is more!");
try{
Session.getDefaultInstance().getTransport().more(s upportedAttachmentPart, true);
}
catch(Exception e){
System.out.println("somthing went wrong");
}
}
//Perform required processing on your attachment here.
//Get the attachment filename.
System.out.println("WML filename: " + supportedAttachmentPart.getFilename());
//Get the attachment size.
System.out.println("Attachment size is: " + supportedAttachmentPart.getSize());
//Get the contents of the attachment.
byte[] temp = (byte[])supportedAttachmentPart.getContent();
System.out.println("byte[].length: " + temp.length);
String data = new String(temp);
System.out.println("Attachment Content: " + data);
}
}
|
The Handler works fine, but I dont get the Content. My byte[] has always a length of 0.
The logfile givs me the follwing:
i'm handling...
trying to get more!
WML filename: roaming.mdata
Attachment size is: 145463
byte[].length: 0
Attachment Content:
I beleave it has something todo with the Transporter an that I don't get the content through the Transport.more ...
I have no Idea what I can do...
Pls. help