0

I am about to automaticaly scan my device for malware files. I use MonkeyRunner to connect, start the Antimalware Software, and start the scan. Here some of the code I use:

device.startActivity(component=runComponent)
MonkeyRunner.sleep(2)
device.touch(250, 750, 'DOWN_AND_UP')
MonkeyRunner.sleep(1)
device.press('KEYCODE_MENU', MonkeyDevice.DOWN_AND_UP)
MonkeyRunner.sleep(1)
device.touch(350, 750, 'DOWN_AND_UP')

pressing the appropriate buttons till the scan starts..

Now I need to sleep the script somehow.. untill the scan complete, to continue with some other actions. Since we dont know for how long will the AV scan, we can't use the sleep function with a specific number...

I was thinkin to do something with the app Activities but dont know what :/

Any ideas would be very usefull

Best regards Giannis

1 Answers1

0

Try using async task. In OnPreExecute() initialize thescript and start it in the background. Then use OnPostExecute() to display the result. This way the user can still do something in the foreground.

Other way would be to use service and create specific event and eventlistener but that will be trickier.

Mazvél
  • 951
  • 1
  • 8
  • 22