Reputation: 38882
I have a UiAutomatorTestCase
:
public class MyUiTest extends UiAutomatorTestCase {
public void testMe() throws UiObjectNotFoundException {
getUiDevice().pressHome();
//How can I start/bind a service in the test case?
//Seems I am not able to get a context in UiAutomatorTestCase
}
}
I am wondering, is it possible to start/bind a service by using startService(...)
or bindService(...)
in this class?
Upvotes: 0
Views: 412
Reputation: 1691
You could try to use:
Runtime.getRuntime().exec("am start -n package/activity");
The code above executes the command in the Android OS shell. This should start an application. For example, to start settings you could replace package/activity with com.android.settings/.Settings.
I don't know if this is what you are looking for. You could give it a shot.
Upvotes: 3