0

我有一个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(...)在此类中启动/绑定服务?

4

1 回答 1

3

您可以尝试使用:

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

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

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

于 2013-10-27T09:59:38.703 回答