I'm just trying to get a notification of incoming and outgoing SMS messages, but I'm having some problems. Here's a minimal test program to demonstrate:
And here's the problem. Everything in brackets is what I do, and the rest is the output that appears in the python output window.import e32
import inbox
import logs
import sys
def handle_incoming_sms(message_id):
- print(u"Incoming SMS: id=" + str(message_id))
- sms_log = logs.sms(mode='in')[0]
- body = sms_log['subject']
- print(u"body= " + body)
- sys.stdout.flush()
def handle_outgoing_sms(message_id):
- print(u"Outgoing SMS: id=" + str(message_id))
- sms_log = logs.sms(mode='out')[0]
- body = sms_log['subject']
- print(u"body= " + body)
- sys.stdout.flush()
the_inbox = inbox.Inbox()
the_inbox.bind(handle_incoming_sms)
the_outbox = inbox.Inbox(inbox.EOutbox)
the_outbox.bind(handle_outgoing_sms)
app_lock = e32.Ao_lock()
app_lock.wait()
[ Send outgoing SMS. Nothing happens. ]
[ Receive incoming SMS. Outputs: ]
Incoming SMS: id=1048669
Outgoing SMS: id=1048669
body=Test out
body=Test in
[ Receive incoming SMS #2. Outputs: ]
Incoming SMS: id=1048670
Outgoing SMS: id=1048670
body=Test out
body=Test in 2
So, sending doesn't really call a handler. But receiving seems to cause both handlers to get called at the same time, so their output is interleaved this way. The outgoing message that appears has the same ID as the incoming, but the body is that of the previously-received message.
![]()

Reply With Quote

. They are a setting in the phone's messaging application, and can cause some strange behaviour with your code (you get the output twice, almost identically), but that's not the cause of your problem.


