SHOW Signed
 

net.rim.blackberry.api.mail
Interface AttachmentHandler


public interface AttachmentHandler

Defines functionality one must implement to perform custom attachment actions.

Guidelines for use

You can implement this interface to create an attachment handler for custom attachments that applications on the RIM device can use.

When an attachment gets created, two bits of information get associated with it: an attachment type and a file name. When being processed through a BES, the content type gets truncated: for example, the content type

  application/x-rimdevice-MySpecialContent
 
gets truncated to
  application/
 
and then, the file name of the attachment appended to produce
  application/MyFileName.ext
 

To accomodate this behaviour, creators of attachments should provide them with filenames that encapsulate the content type:

  x-rimdevice-MySpecialContent-MyFileName.ext
 

Each attachment handler must be able to declare (through the supports(java.lang.String) method) which content types it supports. It is prudent to be as precise as possible when declaring which types can be supported: your implementation should not simply return true for all x-rimdevice content, but rather the specific content types you can handle. With the previous examples in mind, yor method may return true only when tested against the x-rimdevice-MySpecialContent type or even the x-rimdevice-MySpecialContent-MyFileName.txt type.

To alert the system that your handler is available for use, it must register using AttachmentHandlerManager.addAttachmentHandler. Because of the way the system processes incoming messages, your handler will only be eligible to handle content that arrives after you register the handler.

Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.

Since:
JDE 3.6.0

Method Summary
 Category: Signed  String menuString()
          Defines the menu item to display for this attachment handler.
 Category: Signed  void run(Message m, SupportedAttachmentPart p)
          Performs custom processing on an attachment.
 Category: Signed  boolean supports(String contentType)
          Determines whether this attachment handler accepts a specific content type.
 

Method Detail

menuString

public String menuString()
Defines the menu item to display for this attachment handler.

This method is invoked when the user selects an attachment in the Messages screen. Implement this method to return the menu item string to present in the Messages screen when the user selects a supported attachment.

Returns:
Menu item string to present in the Messages screen when this attachment is in focus.
Since:
JDE 3.6.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.

run

public void run(Message m,
                SupportedAttachmentPart p)
Performs custom processing on an attachment.

The system invokes this method when the user selects the corresponding menu item in the Messages screen.

Note: The system invokes this method on the event thread of the Messages application.

Parameters:
m - Message that contains the attachment.
p - Attachment for this attachment handler to process.
Since:
JDE 3.6.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.

supports

public boolean supports(String contentType)
Determines whether this attachment handler accepts a specific content type.

This method is invoked when the handheld receives an attachment. Implement this method to return true only when tested against the particular content type this handler accepts.

Parameters:
contentType - MIME content type.
Returns:
True if this handler accepts the specified content type; otherwise, false.
Since:
JDE 3.6.0
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.



Copyright 1999-2009 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.