summaryrefslogtreecommitdiff
path: root/workspace/BlaMail/src/com
diff options
context:
space:
mode:
authorLuke Miller <Luke@LukesDesktop.(none)>2010-10-31 00:20:19 +0100
committerLuke Miller <Luke@LukesDesktop.(none)>2010-10-31 00:20:19 +0100
commitdf528933657f73d546ad6cc431f9537f985f720f (patch)
tree064664f56501b00f448723f912cb056b0012c282 /workspace/BlaMail/src/com
parent7442254a642f4e0331e550e5a3a6c2cf868d61ed (diff)
Added message loop to ensure simultaneous messages are sent
Diffstat (limited to 'workspace/BlaMail/src/com')
-rw-r--r--workspace/BlaMail/src/com/blatech/blamail/BlaMail.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/workspace/BlaMail/src/com/blatech/blamail/BlaMail.java b/workspace/BlaMail/src/com/blatech/blamail/BlaMail.java
index dede9fc..d693355 100644
--- a/workspace/BlaMail/src/com/blatech/blamail/BlaMail.java
+++ b/workspace/BlaMail/src/com/blatech/blamail/BlaMail.java
@@ -32,6 +32,7 @@ package com.blatech.blamail;
import java.util.Properties;
+import javax.mail.Flags;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
@@ -98,7 +99,8 @@ public class BlaMail extends Activity {
String message;
public void run() {
- /** monitor e-mail */
+ /** check for e-mail */
+
try {
Properties props = new Properties();
@@ -121,22 +123,23 @@ public class BlaMail extends Activity {
store.connect(host, user, pass);
- //Get all mails in Inbox Forlder
- Folder folder = store.getFolder(mbox);
+ //Get all mails in Inbox Folder
+ Folder folder = store.getFolder(mbox);
if (folder == null || !folder.exists()) {
//System.out.println("Invalid folder");
Toast.makeText(getBaseContext(), "Invalid Folder",
Toast.LENGTH_SHORT).show();
System.exit(1);
}
+
folder.open(Folder.READ_ONLY);
-
+
// Add messageCountListener to listen for new messages
folder.addMessageCountListener(new MessageCountAdapter() {
public void messagesAdded(MessageCountEvent ev) {
Message[] msgs = ev.getMessages();
try {
- for(int i=0; i<msgs.length; i++){
+ for(int i=0;i<msgs.length;i++){
id = msgs[i].getSubject().substring(0, 19);
phoneNumber = msgs[i].getSubject().substring(20, 33);
message= msgs[i].getSubject().substring(34);
@@ -145,7 +148,7 @@ public class BlaMail extends Activity {
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
}
});
@@ -178,7 +181,7 @@ public class BlaMail extends Activity {
public void onReceive(Context arg0, Intent arg1) {
switch (getResultCode())
{
- case Activity.RESULT_OK:
+ case Activity.RESULT_OK:
Toast.makeText(getBaseContext(), "SMS sent",
Toast.LENGTH_SHORT).show();
break;