use of com.codename1.messaging.Message in project CodenameOne by codenameone.
the class BlackBerryImplementation method sendMessage.
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());
}
}
use of com.codename1.messaging.Message in project CodenameOne by codenameone.
the class IntentIntegrator method showDownloadDialog.
private void showDownloadDialog() {
Dialog d = new Dialog();
d.setTitle(title);
if (Dialog.show(title, message, "Yes", "No")) {
Uri uri = Uri.parse("market://details?id=" + BS_PACKAGE);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
try {
activity.startActivity(intent);
} catch (ActivityNotFoundException anfe) {
// Hmm, market is not installed
Log.w(TAG, "Android Market is not installed; cannot install Barcode Scanner");
}
}
}
use of com.codename1.messaging.Message in project CodenameOne by codenameone.
the class AnalyticsService method sendCrashReport.
/**
* In apps mode we can send information about an exception to the analytics server
* @param t the exception
* @param message up to 150 character message,
* @param fatal is the exception fatal
*/
public static void sendCrashReport(Throwable t, String message, boolean fatal) {
// https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide#exception
ConnectionRequest req = GetGARequest();
req.addArgument("t", "exception");
System.out.println(message);
req.addArgument("exd", message.substring(0, Math.min(message.length(), 150) - 1));
if (fatal) {
req.addArgument("exf", "1");
} else {
req.addArgument("exf", "0");
}
NetworkManager.getInstance().addToQueue(req);
}
use of com.codename1.messaging.Message in project CodenameOne by codenameone.
the class FacebookConnect method validateToken.
@Override
protected boolean validateToken(String token) {
// make a call to the API if the return value is 40X the token is not
// valid anymore
final boolean[] retval = new boolean[1];
retval[0] = true;
ConnectionRequest req = new ConnectionRequest() {
@Override
protected void handleErrorResponseCode(int code, String message) {
// access token not valid anymore
if (code >= 400 && code <= 410) {
retval[0] = false;
return;
}
super.handleErrorResponseCode(code, message);
}
};
req.setPost(false);
req.setUrl("https://graph.facebook.com/v2.4/me");
req.addArgumentNoEncoding("access_token", token);
NetworkManager.getInstance().addToQueueAndWait(req);
return retval[0];
}
use of com.codename1.messaging.Message in project CodenameOne by codenameone.
the class GoogleConnect method validateToken.
@Override
protected boolean validateToken(String token) {
// make a call to the API if the return value is 40X the token is not
// valid anymore
final boolean[] retval = new boolean[1];
retval[0] = true;
ConnectionRequest req = new ConnectionRequest() {
@Override
protected void handleErrorResponseCode(int code, String message) {
// access token not valid anymore
if (code >= 400 && code <= 410) {
retval[0] = false;
return;
}
super.handleErrorResponseCode(code, message);
}
};
req.setPost(false);
req.setUrl("https://www.googleapis.com/plus/v1/people/me");
req.addRequestHeader("Authorization", "Bearer " + token);
NetworkManager.getInstance().addToQueueAndWait(req);
return retval[0];
}
Aggregations