程序员最近都爱上了这个网站  程序员们快来瞅瞅吧!  it98k网:it98k.com

本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长


+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

Android UserManager.isUserAGoat()的正确用例?

发布于2020-11-14 09:12     阅读(928)     评论(0)     点赞(15)     收藏(5)


我正在查看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");
}

这是源头变化



所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接:http://www.javaheidong.com/blog/article/502/71903ca8183deb0adba3/

来源:java黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

15 0
收藏该文
已收藏

评论内容:(最多支持255个字符)