有什么用ActivityManager.isUserAMonkey()方法?什么用、方法、ActivityManager、isUserAMonkey

2023-09-06 19:29:11 作者:20.温酒叙余生

有什么用ActivityManager.isUserAMonkey()方法?

  ActivityManager.isUserAMonkey()
 

解决方案

它会告诉你,如果用户是测试猴子还是猴子亚军。 孙悟空是一个命令行工具,你可以在任何模拟器或设备上运行。它发送用户事件的伪随机流进入系统,它作为你正在开发的应用软件压力测试。

您可以使用它这样的:

 公共布尔wasItTheMonkey(){

     ActivityManager activityManager =(ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);

     如果(activityManager.isUserAMonkey()){

           Log.d(TAG,这是猴子);
           返回true;

     }

     Log.d(TAG,这是一个用户);
     返回false;
}
 
ActivityManager讲解

请参阅这里

what is the use of ActivityManager.isUserAMonkey() method?

ActivityManager.isUserAMonkey()

解决方案

It will tell you if the user is the Test Monkey or the monkey runner. "The Monkey is a command-line tool that that you can run on any emulator instance or on a device. It sends a pseudo-random stream of user events into the system, which acts as a stress test on the application software you are developing."

You can use it like that:

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;
}

See here.