Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (3.5k points)

I was looking at the new APIs introduced in Android 4.2. While looking at the UserManager class I came across the following method:

public boolean isUserAGoat()

Used to determine whether the user making this call is subject to teleportation.

Returns whether the user making this call is a goat.

How and when should this be used?

1 Answer

0 votes
by (46k points)

From Java's origin, the technique used to deliver false until it was changed in API 21.

/**

 * Used to decide whether the user doing this call is subject to

 * teleportations.

 * @return whether the user executing this call is a goat 

 */

public boolean isUserAGoat() {

    return false;

}

It seems like the process has no real value for us as developers. Someone has earlier stated that this might be an Easter egg.

In API 21 the implementation was modified to verify if there is an established app with the package com.coffeestainstudios.goatsimulator

/**

 * Used to tell whether the user making this call is subject to

 * teleportations.

 *

 * <p>As of {@link android.os.Build.VERSION_CODES#LOLLIPOP}, this method can

 * now automatically know goats using advanced goat recognition technology.</p>

 *

 * @return Returns true if the user making this call is a goat.

 */

public boolean isUserAGoat() {

    return mContext.getPackageManager()

            .isPackageAvailable("com.coffeestainstudios.goatsimulator");

}

Check out the source and the change.

Related questions

0 votes
1 answer
0 votes
1 answer
asked Nov 13, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...