Package javax.wireless.messaging

Examples of javax.wireless.messaging.MessagePart


        // Check that content has not already been added. For this sample there
        // is no point in attaching the same file twice. Note that every
        // MessagePart contained within a MultipartMessage must have a unique
        // content id.
        for (int i = 0; i < getMessageParts().getNumberOfRows(); i++) {
            final MessagePart messagePart =
                    (MessagePart) getMessageParts().getRow(i);
            final String contentLocation = messagePart.getContentLocation();
            if (contentLocation.equals(FOLDER_NAMES[type] + '0'
                    + EXTENSIONS[type])) {
                exists = true;
            }
        }
        if (!exists) {
            // Obtain content data from project resource
            final String filename = FOLDER_NAMES[type] + "0" + EXTENSIONS[type];
            final StringBuffer path = new StringBuffer("/media/");
            path.append(FOLDER_NAMES[type]);
            path.append("/");
            path.append(filename);
            final InputStream inputStream =
                    getClass().getResourceAsStream(path.toString());
            try {
                final byte[] contentData =
                        IOUtilities.streamToBytes(inputStream);

                // Create a MessagePart object with the contentData and add it
                // to the message parts vector
                final MessagePart messagePart =
                        new MessagePart(contentData, MIME_TYPES[type],
                                FOLDER_NAMES[type], filename, null);
                addMessagePart(messagePart);
            } catch (final IOException ioe) {
                errorDialog(ioe.toString());
            }
View Full Code Here


                        (MultipartMessage) ((MessageConnection) _sendConn)
                                .newMessage(MessageConnection.MULTIPART_MESSAGE);
                multipartMessage.setSubject(subject);

                // Add the message text to the multipart message
                multipartMessage.addMessagePart(new MessagePart(message
                        .getBytes(), "text/plain", "text", null, null));

                // Add any attachments
                for (int i = 0; i < _messageParts.getNumberOfRows(); i++) {
                    multipartMessage.addMessagePart((MessagePart) _messageParts
View Full Code Here

            _multipartMessage = multipartMessage;
        }

        public void run() {
            // Obtain the message part containing the message body
            final MessagePart textMsgPart =
                    _multipartMessage.getMessagePart("text");

            if (textMsgPart != null) {
                final byte[] bytes = textMsgPart.getContent();
                _msgText = new String(bytes);
            }

            final MessagePart pictureMsgPart =
                    _multipartMessage.getMessagePart("picture");
            if (pictureMsgPart != null) {
                final byte[] pictureData = pictureMsgPart.getContent();
                _bitmap = Bitmap.createBitmapFromBytes(pictureData, 0, -1, 1);
            }

            invokeLater(new Runnable() {
                public void run() {
View Full Code Here

        // Create a data template that will format the model data as an array of
        // LabelFields
        final DataTemplate dataTemplate = new DataTemplate(_view, 1, 1) {
            public Field[] getDataFields(final int modelRowIndex) {
                final MessagePart message =
                        (MessagePart) _app.getMessageParts().getRow(
                                modelRowIndex);
                final Field[] fields =
                        { new LabelField(message.getContentLocation(),
                                Field.NON_FOCUSABLE | DrawStyle.ELLIPSIS) };
                return fields;
            }
        };
View Full Code Here

TOP

Related Classes of javax.wireless.messaging.MessagePart

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.