Reputation: 25164
I found the following function in package android.app.ActivityManager
.
public static boolean isUserAMonkey ()
The reference describes:
public static boolean isUserAMonkey ()
Since: API Level 8Returns "true" if the user interface is currently being messed with by a monkey.
I was shocked by this strange function. And have a few questions.
What does this (user interface is currently being messed with by a monkey) mean?
What is the practical use of this function?
Why do they use isUserAMonkey
for the function name?
Upvotes: 169
Views: 34177
Reputation: 5167
The story of how this method was created is quite interesting and i couldn't resist sharing it. I think it explains perfectly why such a method is needed.
"One day i walked into the monkey lab to hear a voice say, '911 -What's your emergency?" That situation resulted in Dianne adding a new function to the API,
isUserAMonkey()
which is used to gate actions that monkeys shouldn't take during tests (including dialing the phone and resetting the device).Androids: The Team That Built the Android Operating System (Haase, Chet)
Upvotes: 1
Reputation: 3924
This method is for checking whether the current user is a test user by some automatic testing, called 'monkey' by Android devs.
Upvotes: 114
Reputation: 1945
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.
just refer these links also:
Upvotes: 38