我正在檢視 Android 4.2 中引入的新API. 在檢視 UserManager
類時,我遇到了以下方法:
public boolean isUserAGoat()
用來確定這個呼叫的使用者是否受到傳送。
返回打這個電話的使用者是否是山羊。
應該如何以及何時使用?
我正在檢視 Android 4.2 中引入的新API. 在檢視 UserManager
類時,我遇到了以下方法:
public boolean isUserAGoat()
用來確定這個呼叫的使用者是否受到傳送。
返回打這個電話的使用者是否是山羊。
應該如何以及何時使用?
從它們的 源 ,返回 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");
}