当前位置: 首页>>代码示例>>Java>>正文


Java Message类代码示例

本文整理汇总了Java中com.codename1.messaging.Message的典型用法代码示例。如果您正苦于以下问题:Java Message类的具体用法?Java Message怎么用?Java Message使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Message类属于com.codename1.messaging包,在下文中一共展示了Message类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendMessage

import com.codename1.messaging.Message; //导入依赖的package包/类
@Override
public void sendMessage(String[] recieptents, String subject, Message msg) {
    String[] attachments = null;
    String[] attachmentMime = null;
    
    if(msg.getAttachments().size() > 0) {
        int counter = 0;
        attachments = new String[msg.getAttachments().size()];
        attachmentMime = new String[attachments.length];
        for(String s : msg.getAttachments().keySet()) {
            String mime = msg.getAttachments().get(s);
            attachments[counter] = s;
            attachmentMime[counter] = mime;
            counter++;
        }
    }
    
    nativeInstance.sendEmailMessage(recieptents, subject, msg.getContent(),  
            attachments, attachmentMime, msg.getMimeType().equals(Message.MIME_HTML));
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:21,代码来源:IOSImplementation.java

示例2: sendMessage

import com.codename1.messaging.Message; //导入依赖的package包/类
@Override
public void sendMessage(String[] recieptents, String subject, Message msg) {
    if(recieptents != null){
        try {
            String mailto = "mailto:" + recieptents[0];
            for(int iter = 1 ; iter < recieptents.length ; iter++) {
                mailto += "," + recieptents[iter];
            }
            mailto += "?body=" + Util.encodeUrl(msg.getContent()) + "&subject=" + Util.encodeUrl(subject);
            Desktop.getDesktop().mail(new URI(mailto));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        System.out.println("sending message to " + recieptents[0]);
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:17,代码来源:JavaSEPort.java

示例3: registeredForPush

import com.codename1.messaging.Message; //导入依赖的package包/类
public void registeredForPush(String deviceId) {
    Dialog.show("Push Registered", "Device ID: " + deviceId + "\nDevice Key: " + Push.getPushKey(), "OK", null);
    String k = Push.getPushKey();
    if(k != null) {
        s.findDeviceKey().setText("Device Key: " + k);
    }
    
    Message m = new Message(Push.getPushKey());
    Display.getInstance().sendMessage(new String[] {"[email protected]"}, "Push key", m);
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:11,代码来源:PushDemo.java

示例4: createDemo

import com.codename1.messaging.Message; //导入依赖的package包/类
public Container createDemo() {
    Container message = new Container(new BoxLayout(BoxLayout.Y_AXIS));        
    ComponentGroup gp = new ComponentGroup();
    message.addComponent(gp);
    
    final TextField to = new TextField("");
    to.setHint("TO:");
    gp.addComponent(to);

    final TextField subject = new TextField("Codename One Is Cool");
    subject.setHint("Subject");
    gp.addComponent(subject);
    final TextField body = new TextField("Try it out at http://www.codenameone.com/");
    body.setSingleLineTextArea(false);
    body.setRows(4);
    body.setHint("Message Body");
    gp.addComponent(body);
    
    ComponentGroup buttonGroup = new ComponentGroup();
    Button btn = new Button("Send");
    buttonGroup.addComponent(btn);
    message.addComponent(buttonGroup);
    btn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            Message msg = new Message(body.getText());
            Display.getInstance().sendMessage(new String[] {to.getText()}, subject.getText(), msg);
        }
    });
            
    return message;
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:32,代码来源:Mail.java

示例5: sendMessage

import com.codename1.messaging.Message; //导入依赖的package包/类
public void sendMessage(String[] recieptents, String subject, Message msg) {
    String mailto = "mailto:" + recieptents[0];
    for(int iter = 1 ; iter < recieptents.length ; iter++) {
        mailto += "," + recieptents[iter];
    }
    mailto += "?body=" + Util.encodeUrl(msg.getContent()) + "&subject=" + Util.encodeUrl(subject);
    execute(mailto);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:9,代码来源:GameCanvasImplementation.java

示例6: sendMessage

import com.codename1.messaging.Message; //导入依赖的package包/类
public void sendMessage(String[] recipients, String subject, Message msg) {
    Folder folders[] = Session.getDefaultInstance().getStore().list(Folder.SENT);
    net.rim.blackberry.api.mail.Message message = new net.rim.blackberry.api.mail.Message(folders[0]);
    try {
        Address toAdds[] = new Address[recipients.length];
        for (int i = 0; i < recipients.length; i++) {
            Address address = new Address(recipients[i], "");
            toAdds[i] = address;
        }
        message.addRecipients(net.rim.blackberry.api.mail.Message.RecipientType.TO, toAdds);
        message.setSubject(subject);
    } catch (Exception e) {
        EventLog.getInstance().logErrorEvent("err " + e.getMessage());            
    }

    try {

        if (msg.getAttachment() != null && msg.getAttachment().length() > 0) {
            Multipart content = new Multipart();
            TextBodyPart tbp = new TextBodyPart(content,msg.getContent());                
            content.addBodyPart(tbp);
            
            InputStream stream = com.codename1.io.FileSystemStorage.getInstance().openInputStream(msg.getAttachment());
            byte[] buf;
            buf = IOUtilities.streamToBytes(stream);
            stream.close();
            String name = msg.getAttachment();
            name = name.substring(name.lastIndexOf(getFileSystemSeparator()) + 1, name.length());
            SupportedAttachmentPart sap = new SupportedAttachmentPart(content, msg.getAttachmentMimeType(), name, buf);
            content.addBodyPart(sap);                
            message.setContent(content);
        } else {
            message.setContent(msg.getContent());
        }

        app.setWaitingForReply(true);
        Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, new MessageArguments(message));
    } catch (Exception ex) {
        EventLog.getInstance().logErrorEvent("err " + ex.getMessage());
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:42,代码来源:BlackBerryImplementation.java

示例7: sendMessage

import com.codename1.messaging.Message; //导入依赖的package包/类
/**
 * @inheritDoc
 */
public void sendMessage(String[] recipients, String subject, Message msg) {
    if(editInProgress()) {
        stopEditing();
    }
    Intent emailIntent;
    String attachment = msg.getAttachment();
    boolean hasAttachment = (attachment != null && attachment.length() > 0) || msg.getAttachments().size() > 0;
        
    if(msg.getMimeType().equals(Message.MIME_TEXT) && !hasAttachment){
        StringBuilder to = new StringBuilder();
        for (int i = 0; i < recipients.length; i++) {
            to.append(recipients[i]);
            to.append(";");
        }
        emailIntent = new Intent(Intent.ACTION_SENDTO,
                Uri.parse(
                "mailto:" + to.toString()
                + "?subject=" + Uri.encode(subject)
                + "&body=" + Uri.encode(msg.getContent())));        
    }else{
        if (hasAttachment) {
            if(msg.getAttachments().size() > 0) {
                emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
                emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, recipients);
                emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
                emailIntent.setType(msg.getMimeType());
                ArrayList<Uri> uris = new ArrayList<Uri>();
                
                for(String path : msg.getAttachments().keySet()) {
                    uris.add(Uri.parse(fixAttachmentPath(path)));
                }
                
                emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
            } else {
                emailIntent = new Intent(android.content.Intent.ACTION_SEND);
                emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, recipients);
                emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
                emailIntent.setType(msg.getMimeType());
                emailIntent.setType(msg.getAttachmentMimeType());
                //if the attachment is in the uder home dir we need to copy it 
                //to an accessible dir
                attachment = fixAttachmentPath(attachment);
                emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(attachment));
            }
        } else {
            emailIntent = new Intent(android.content.Intent.ACTION_SEND);
            emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, recipients);
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
            emailIntent.setType(msg.getMimeType());
        }
        if (msg.getMimeType().equals(Message.MIME_HTML)) {
            emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(msg.getContent()));                                
        }else{
            emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, msg.getContent());                    
        }
        
    }
    final String attach = attachment;
    AndroidNativeUtil.startActivityForResult(Intent.createChooser(emailIntent, "Send mail..."), new IntentResultListener() {

        @Override
        public void onActivityResult(int requestCode, int resultCode, Intent data) {
            if(attach != null && attach.length() > 0 && attach.contains("tmp")){
                FileSystemStorage.getInstance().delete(attach);
            }
        }
    });
}
 
开发者ID:shannah,项目名称:cn1,代码行数:72,代码来源:AndroidImplementation.java

示例8: sendMessage

import com.codename1.messaging.Message; //导入依赖的package包/类
/**
 * <p>Send an email using the platform mail client.<br>
 * The code below demonstrates sending a simple message with attachments using the devices
 * native email client:
 * </p>
 * <script src="https://gist.github.com/codenameone/3db47a2ff8b35cae6410.js"></script>
 * @param subject e-mail subject
 * @param msg the Message to send
 * @param recipients array of e-mail addresses
 */
public static void sendMessage(String subject, Message msg, String... recipients) {
    Display.impl.sendMessage(recipients, subject, msg);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:14,代码来源:CN.java

示例9: sendMessage

import com.codename1.messaging.Message; //导入依赖的package包/类
/**
 * <p>Send an email using the platform mail client.<br>
 * The code below demonstrates sending a simple message with attachments using the devices
 * native email client:
 * </p>
 * <script src="https://gist.github.com/codenameone/3db47a2ff8b35cae6410.js"></script>
 * @param recipients array of e-mail addresses
 * @param subject e-mail subject
 * @param msg the Message to send
 */
public void sendMessage(String[] recipients, String subject, Message msg) {
    impl.sendMessage(recipients, subject, msg);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:14,代码来源:Display.java

示例10: sendMessage

import com.codename1.messaging.Message; //导入依赖的package包/类
/**
 * Send an email using the platform mail client
 * @param recipients array of e-mail addresses
 * @param subject e-mail subject
 * @param msg the Message to send
 */
public void sendMessage(String[] recipients, String subject, Message msg) {
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:9,代码来源:CodenameOneImplementation.java

示例11: sendMessage

import com.codename1.messaging.Message; //导入依赖的package包/类
/**
 * Send an email using the platform mail client
 * @param recipients array of e-mail addresses
 * @param subject e-mail subject
 * @param msg the Message to send
 */
public void sendMessage(String[] recipients, String subject, Message msg) {
    impl.sendMessage(recipients, subject, msg);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:10,代码来源:Display.java


注:本文中的com.codename1.messaging.Message类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。