ActivityManager in Android API

public static boolean isUserAMonkey ()
Returns „true“ if the user interface is currently being messed with by a monkey.