问题

我在查看 Android 4.2 中介绍的新API . 在查看 UserManager 课程时,我来了通过以下方法:

public boolean isUserAGoat()

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

Returns whether the user making this call is a goat.

如何使用和何时使用?



解决方法

从他们的 ,用于返回 false 的方法,直到在API 21中更改.

/**
 * 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;
}

看起来该方法对我们作为开发人员没有真正的用途.有人之前表示可能是 复活节彩蛋 .

编辑:

在API 21中,实施已更改,以检查是否有安装的应用程序包 com.coffeestainstudios.goatsimulator

/**
 * 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");
}

以下是更新的 源链接




相关问题推荐