View Single Post
Old 08-11-2008, 10:42 AM   #6 (permalink)
Thumbs Must Hurt
Join Date: Apr 2006
Location: Boston
Model: 8900
Carrier: AT&T
Posts: 98
Post Thanks: 0
Thanked 0 Times in 0 Posts


Some things to think about. As of OS 4.1, registering your attachment handler object with the AttachmentHandlerManager should be a one-time only event. This is because the OS caches the object, and does not release/delete it. So if your application is registering an attachment handler every time your app launches, another one will be added to the list the OS is caching. This is why you should only register your attachment handler with the OS once for every time the device is turned on - this can be arranged through an "Alternate Entry Point" mechanism.

public void run (Message m, SupportedAttachmentPart sap )
String data = new String((byte[])sap.getContent());
The above code turns the contents of the attachment into a String, which can be checked for length. You can avoid the String conversion and just pull the contents out with

Object contents = sap.getContent();
It should be coming in as a byte array (byte[]) but setting it to an Object makes it easier to perform null checking (for me, anyway). If the Object is non-null, you can convert it to a byte array and then check its length.


Karl G. Kowalski
Owns a RAZR
Develops for BlackBerry
So next phone will iPhone 3G!
Offline   Reply With Quote