【发布时间】:2012-04-09 19:13:17
【问题描述】:
ActivityManager.isUserAMonkey()方法有什么用?
ActivityManager.isUserAMonkey()
【问题讨论】:
标签: android
ActivityManager.isUserAMonkey()方法有什么用?
ActivityManager.isUserAMonkey()
【问题讨论】:
标签: android
它会告诉你用户是Test Monkey 还是monkey runner。 “Monkey 是一个命令行工具,您可以在任何模拟器实例或设备上运行它。它将用户事件的伪随机流发送到系统中,作为您正在开发的应用程序软件的压力测试。”
你可以这样使用它:
public boolean wasItTheMonkey(){
ActivityManager activityManager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
if(activityManager.isUserAMonkey()) {
Log.d(TAG,"it was the monkey");
return true;
}
Log.d(TAG,"it was an user");
return false;
}
【讨论】:
Monkey 是一个 Android 测试套件,旨在为您的应用程序提供可重现的输入事件。我想该方法与此有关。
【讨论】:
如果用户界面当前被猴子弄乱,则此函数返回“true”。猴子是在您的模拟器或设备上运行的程序,并生成用户事件的伪随机流,例如点击、触摸,或手势,以及一些系统级事件。您可以使用 Monkey 以随机但可重复的方式对您正在开发的应用程序进行压力测试....See this link
【讨论】: