Android: Read/Send text messages on Ubuntu?
As an android programmer I spend an awful lot of time with my test device (phone) plugged into my computer. And being as lazy as I am, I would like to be able to send texts via my computer through my phone.
For example: I get a text, The text is pushed to the active ADB connection from which I can send it to a running script that will allow me to see the text on my computer. I can then type the response, hit enter, which will push t开发者_如何学编程he text through the active ADB connection, to the phone and be sent to the target.
Is there any way I do this? Maybe there is an ADB command that I can route through a python script or something?
I recommend SL4A scripting layer. You can connect to SL4A hosted server via adb or tcp/ip, and then execute script to send SMS. Among several script language supported by SL4A, I think python API is most mature and useful.
SL4A Remote Control:
http://code.google.com/p/android-scripting/wiki/RemoteControl
SL4A SMS API:
http://code.google.com/p/android-scripting/wiki/ApiReference#smsSend
Try this one:
adb shell am start -S -e sms_body 'your message body' \
-e address receiver -t 'vnd.android-dir/mms-sms' \
com.android.mms/com.android.mms.ui.ComposeMessageActivity \
&& adb shell input keyevent 66
Explainations:
-S: force stop the target app before starting the activity
-e sms_body 'your message body': add extra key-value data
as sms_body=>'sms body'
-e address phone-number: similar to the above
-t vnd.android-dir/mms-sms: MIME type
com.android.mms/com.android.mms.ui.ComposeMessageActivity:
target pkg/activity component
adb shell input keyevent 66: finally hit the enter key
You can use gmail for this, on the chat widget in your gmail page, mouse over the contact you want to sms. Click the more button and you will see a send sms option. If you don't already have a phone number for that contact it will prompt you to enter a phone number. I just added myself to my contacts in gmail to send myself texts.
精彩评论