使用子进程执行ADB命令
问题描述:
我正在使用adb发送SMS。下面的命令 ./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 = './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) }
不幸的是这个脚本列出了亚行的版本和所有可用选项;没有警告,没有错误。 预先感谢任何帮助
答
制作shell
一个单独的参数:
call(['adb', 'shell', 'am start -a android.intent.action.SENDTO ...'])