I need to send MMS by writing a MonkeyRunner script. My script is as below and it throws an exception. Can anyone please help? I am interested in writing scripts using intents and not using co-ordinates method:
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] Script terminated due to an exception
130508 12:37:35.663:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]Synta xError: ("mismatched input 'sendIntent' expecting 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.parse(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]
at org.python.core.builtin.execfile_flags(builtin.java:530)
130508 12:37:35.663:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at 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]
at com.android.monkeyrunner.MonkeyRunnerStarter.run(MonkeyRunnerStarter.java:77)
130508 12:37:35.663:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]
at com.android.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter.java:18 9)