0

I have a simple requirement to run a set of files on url on MediaPlayer. I am writing a script to do this.

There is a variable mediapath in MainActivity.java which takes url path. Is it possible to give this variable url value using android monkeyrunner script. currently there is no device.set function to set the particular value.

My script is:

from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
device = MonkeyRunner.waitForConnection()
package = 'com.example.diagplayer'
activity = 'com.example.diagplayer.MainActivity'
file = open('filelist.txt', 'r')
rows = file.readlines()
for file_name in rows:
    uri=file_name
extra = {}
extra['URI']=uri
print(uri)
runComponent = package + '/' + activity
device.set("MediaPath","uri")//getting error here
device.touch(100, 350, MonkeyDevice.DOWN) 
device.touch(10,350, 'DOWN_AND_UP')
Axel
  • 13,939
  • 5
  • 50
  • 79
Mayank Agarwal
  • 447
  • 1
  • 7
  • 21
  • @JonathonReinhart: FYI this is Jython, not Java. The definition of what is/is not a script is a whole can of worms. – cdarke Feb 25 '14 at 08:51

1 Answers1

0

It would be impossible for a device.set() method to set a variable in a running Activity, which I think is your intention.

However you can set the extras of the Intent with the desired values (as you did) and then make your Activity extract them and set the variables.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134