Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get an instance of android.app.UiAutomation

I am testing some new features of Android 5.0, and now is the round of the UiAutomator and the new method implemented. I've tried to search for an example/guide, then I've tried to get an instance of UiAutomator by

getSystemService()

but that was not helpful. My goal is to use executeShellCommands(String str).

Has anyone already implemented?

like image 466
alex_au Avatar asked Nov 21 '14 16:11

alex_au


1 Answers

Just to clarify, the UiAutomation class is not part of UiAutomator (although they have similar names).

You can obtain a UiAutomation instance by calling Instrumentation#getUiAutomation(). This only works if you're running an Instrumentation-based test.

If this is part of a shell-based UiAutomator test, then you can use Runtime#exec() to execute a shell command.

like image 114
Allen Hair Avatar answered Sep 29 '22 16:09

Allen Hair