Blackberry JAVA DEVELOPMENT ENVIRONMENT - - CRYPTOGRAPHIC SMART CARD DRIVER - DEVELOPMENT GUIDE Anleitung zur Fehlerbehebung Seite 161

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 286
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 160
161
10: Using the messages application
Send a message with an attachment
Retrieve information about the
attachment.
> Invoke the methods of the SupportedAttachmentPart class. The
SupportedAttachmentPart class represents an attachment with a corresponding viewer on
the BlackBerry® device. An
UnsupportedAttachmentPart represents an attachment that
does not have a viewer on the BlackBerry device.
public void run(Message m, SupportedAttachmentPart p) {
...
String name = p.getName();
int size = p.getSize();
}
Task Steps
Create a multipart message.
> Create a new Multipart object.
byte[] buf = new byte[256]; // The attachment.
MultiPart multipart = new MultiPart(); // Default type of multipart/
mixed.
Create each component of the
attachment.
>Create a SupportedAttachmentPart object, designating the Multipart object as its
parent.
SupportedAttachmentPart attach = new SupportedAttachmentPart(
multipart, "application/x-example", "filename", data);
Add each SupportedAttachmentPart
object to the multipart object.
>Invoke addBodyPart(SupportedAttachmentPart) on that object.
multipart.addBodyPart(attach); // Add the attachment to the multipart.
Set the content of the attachment. >Invoke setContent(Multipart) on the Message object and pass in the Multipart
object as its parameter.
msg.setContent(multipart);
Send the message. >Invoke Transport.send().
Transport.send(msg);
Task Steps
Seitenansicht 160
1 2 ... 156 157 158 159 160 161 162 163 164 165 166 ... 285 286

Kommentare zu diesen Handbüchern

Keine Kommentare