我在看Android 4.2年推出的新API.
public boolean isUserAGoat()
用于确定进行此呼叫的用户是否受传送的影响.
返回进行此调用的用户是否为山羊.
该如何以及何时使用?
我在看Android 4.2年推出的新API.
public boolean isUserAGoat()
用于确定进行此呼叫的用户是否受传送的影响.
返回进行此调用的用户是否为山羊.
该如何以及何时使用?
在Android R中,此方法总是返回false.谷歌表示,这样做是"为了保护山羊的隐私":
/**
* 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>
*
* <p>As of {@link android.os.Build.VERSION_CODES#R}, this method always returns
* {@code false} in order to protect goat privacy.</p>
*
* @return Returns whether the user making this call is a goat.
*/
public boolean isUserAGoat() {
if (mContext.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.R) {
return false;
}
return mContext.getPackageManager()
.isPackageAvailable("com.coffeestainstudios.goatsimulator");
}
从100开始,该方法用于返回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;
}
看起来这个方法对我们这些开发者来说没有实际的用处.之前有人说可能是100.
在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");
}