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

This question already has an answer here:

  • Strange function in ActivityManager: isUserAMonkey. What does this mean, what is its use? 2 answers

  • 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.


    Monkey is an Android test suite designed to provide reproducible input events to your application. I would imagine the method is related to that.


    This function returns "true" if the user interface is currently being messed with by a monkey..and The Monkey is a program that runs on your emulator or device and generates pseudo-random streams of user events such as clicks, touches, or gestures, as well as a number of system-level events. You can use the Monkey to stress-test applications that you are developing, in a random yet repeatable manner.... See this link

    链接地址: http://www.djcxy.com/p/16232.html

    上一篇: 在JavaScript中创建全局唯一ID

    下一篇: ActivityManager.isUserAMonkey()方法有什么用?