Send and Receive SMS
Learn:
- Send SMS
- Receive SMS
Send SMS
sms_write.py
import android
droid = android.Android()
number = droid.dialogGetInput('Send SMS', 'Phone Number?').result
message = 'Test SMS'
result = droid.smsSend(number, message)
Code Explained
number = droid.dialogGetInput('Send SMS', 'Phone Number?').result
Get the phone number you want to send the SMS to. When you start 2 instances of the emulator, you can send SMS from one to the other using the port number as the phone number.
result = droid.smsSend(number, message)
Send the SMS
Receive SMS
sms_read.py
import android
droid = android.Android()
SMSmsgs = droid.smsGetMessages(False, 'inbox').result
for message in SMSmsgs:
print 'From: '+message['address']+' > '+message['body']+'\n'
Code Explained
SMSmsgs = droid.smsGetMessages(False, 'inbox').result
Note that all the messages in the inbox are read.
More methods like delete SMS can be found in the SmsFacade documentation.
Scan the script to your smartphone using the Test EMANT380 app or download to PC/Emulator