在UiAutomatorTestCase中启动/绑定服务

时间:2013-10-25 14:31:15

标签: android android-intent uiautomator

我有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
   }
}

我想知道,是否可以在此课程中使用startService(...)bindService(...)来启动/绑定服务?

1 个答案:

答案 0 :(得分:3)

您可以尝试使用:

Runtime.getRuntime().exec("am start -n package/activity");

上面的代码执行Android OS shell中的命令。这应该启动一个应用程序。例如,要启动设置,您可以使用com.android.settings / .Settings替换包/活动。

我不知道这是不是你要找的。你可以试一试。

相关问题