When is UserManager.isUserAgot() used on Android?

Asked 2 years ago, Updated 2 years ago, 43 views

I'm studying Android 4.2 API and I'm using isUserAGoat() in UserManager There's a method

It says it's a method to return whether the caller is a goat or not When do you use this?

java android usermanager

2022-09-22 14:57

1 Answers

Looking at the source before the API 21 changed, /** * * Used to determine whether the user making this call is subject to * * teleportations. * * @return whether the user making this call is a goat */ public boolean isUserAGoat() { return false; } It returns false like this way. I think it's Easter egg.
It won't actually be used.

If you look at API21, the contents have been modified

    /**
     * * Used to determine 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 identify 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");
    }

It has been changed to check if the installed app includes the com.coffeestainstudios.goatssimulator package.


2022-09-22 14:57

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.