gtiwari333
gtiwari333

Reputation: 25164

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

I found the following function in package android.app.ActivityManager.

public static boolean isUserAMonkey ()

The reference describes:

public static boolean isUserAMonkey () Since: API Level 8

Returns "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.

Upvotes: 169

Views: 34177

Answers (3)

Sarantis Tofas
Sarantis Tofas

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

HefferWolf
HefferWolf

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

harikrishnan
harikrishnan

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

Related Questions