Uiautomator"我开始" [英] Uiautomator "am start"
本文介绍了Uiautomator"我开始"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有任何身体知道如何调用
上午开始-a活动
从 uiautomator
code。
或者是有可能直接从 JUnit的启动活动
code。
Does any body know how to call
am start -a ACTIVITY
from uiautomator
code.
Or is it possible to start activity right from junit
code.
推荐答案
下面是我用它来开始从.jar文件的活动的一个例子:
Here's an example I use to start an activity from the .jar file:
private boolean startSettings() {
try {
Runtime.getRuntime().exec(
"am start -n com.android.settings/.Settings");
sleep(1000);
} catch (IOException e) {
e.printStackTrace();
}
for (int i = 0; i < 5; i++) {
sleep(1000);
if (getUiDevice().getCurrentPackageName().contains(
"com.android.settings")) {
return true;
}
}
return false;
}
您可以修改code启动任何应用程序。您也可以使方法更通用,加入一个参数为包/活性值。
You can modify the code to start any app. You could also make the method more generic by adding a parameter for the package/ activity value.
这篇关于Uiautomator&QUOT;我开始&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文