使用子进程执行ADB命令

时间:2013-07-30 08:31:04

标签: android python call subprocess adb

我正在使用adb发送短信。以下命令 ./adb shell am start -a android.intent.action.SENDTO -d sms:12345 --es sms_body "the body" --ez exit_on_sent true 虽然输入并在bash中执行,但它的工作是否正常,但我的python脚本似乎只调用./adb

    ADB = './adb'
    def callSMScmd(msg, num):
        adbArgs = ('shell am start -a '
                +'android.intent.action.SENDTO -d sms:'+str(num)+' --es'
                +'sms_body "'+msg+'" --ez exit_on_sent true')
        call([ADB, adbArgs])

正确的回复是Starting: Intent { act=android.intent.action.SENDTO dat=sms:12345 (has extras) }不幸的是,此脚本列出了adb版本和所有可用选项;没有警告,没有错误。 在此先感谢您的任何帮助

1 个答案:

答案 0 :(得分:2)

使shell成为一个单独的参数:

call(['adb', 'shell', 'am start -a android.intent.action.SENDTO ...'])
相关问题