正确使用的情况下为Android UserManager.isUserAGoat()? [英] Proper use cases for Android UserManager.isUserAGoat()?
问题描述
我一直在寻找在的Android 4.2 推出了新的API。 在注视<一href="http://developer.android.com/reference/android/os/UserManager.html"><$c$c>UserManager$c$c>一流的我碰到下面的方法:
I was looking at the new APIs introduced in Android 4.2.
While looking at the UserManager
class I came across the following method:
公共布尔isUserAGoat()
public boolean isUserAGoat ()
用于确定在进行此调用用户是否受到teleportations。
Used to determine whether the user making this call is subject to teleportations.
返回在进行此调用用户是否是山羊。
Returns whether the user making this call is a goat.
如何以及何时该使用?
推荐答案
从他们的 <一个href="https://android.googlesource.com/platform/frameworks/base/+/android-5.0.0_r6/core/java/android/os/UserManager.java#433">source,该方法用于返回假
,直到它在21 API被改变。
From their source, the method used to return false
until it was changed in 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;
}
它看起来像方法没有真正使用我们作为开发商。有人做过previously表示,它可能是一个 复活节彩蛋 。
It looks like the method has no real use for us as developers. Someone has previously stated that it might be an Easter egg.
编辑:
在21 API执行改为检查是否有与包的安装的应用程序 com.coffeestainstudios.goatsimulator
In API 21 the implementation was changed to check if there is an installed app with the package 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");
}
下面是更新后的 <一个href="https://android.googlesource.com/platform/frameworks/base/+/android-5.0.0_r6/core/java/android/os/UserManager.java">source链接
Here is the updated source link
这篇关于正确使用的情况下为Android UserManager.isUserAGoat()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!