本文整理汇总了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));
}
示例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]);
}
}
示例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);
}
示例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;
}
示例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);
}
示例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());
}
}
示例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);
}
}
});
}
示例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);
}
示例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);
}
示例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) {
}
示例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);
}