我需要通过编写 MonkeyRunner 脚本来发送彩信。我的脚本如下,它会引发异常。有人可以帮忙吗?我有兴趣使用意图而不是使用坐标方法编写脚本:
from com.android.monkeyrunner import MonkeyDevice, MonkeyRunner, MonkeyImage
device= MonkeyDevice
for i in range(5):
device =MonkeyRunner.waitForConnection(8)
if device != None:
print "Device found..."
break;
Intent sendIntent = new Intent("android.intent.action.SEND_MSG");
sendIntent.putExtra("999999", toText);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "MMS");
sendIntent.putExtra("sms_body", textMessage);
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/file.gif")));
sendIntent.setType("image/jpeg");
device.startActivity(sendIntent);
130508 12:37:35.663:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] 脚本因异常而终止
130508 12:37:35.663:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] Synta xError: ( “不匹配的输入 'sendIntent' 期待 NEWLINE”,('C:\Users\halappa\Work\MMBU\EOS2\ES2\Samsung\adt-bundle-windows-x86_64-20130219\adt-bundle -windows-x86_64-20130219\sdk \tools\mms.py', 9, 7, 'Intent sendIntent = new Intent("android.intent.action.SEND_MSG"); \n'))
130508 12:37:35.663:S [main] [com.android .monkeyrunner.MonkeyRunnerOptions]
at org.python.core.ParserFacade.fixParseError(ParserFacade.java:94)
130508 12:37:35.663:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at org.python.core.ParserFacade .解析(ParserFacade.java:143)
130508 12:37:35.663:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at org.python.core.Py.compile_flags(Py.java:1644)
130508 12:37:35.663:S [main] [com .android.monkeyrunner.MonkeyRunnerOptions]
在 org.python.core。org.python.util.PythonInterpreter.execfile ( PythonInterpreter.java:156 ) 130508 12
:37:35.663:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] at com.android.monkeyrunner.ScriptRunner.run(ScriptRunner.java:116) 130508 12:37:35.663:S [main] [com.android. monkeyrunner.MonkeyRunnerOptions]
在 com.android.monkeyrunner.MonkeyRunnerStarter.run(MonkeyRunnerStarter.java:77)
130508 12:37:35.663:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
在 com.android.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter.爪哇:18 9)