【Android】Google真能搞之 isUserAMonkey()

ActivityManager 类, 相信大家都不陌生。 从API Level 1开始就有了。

但是从Level 8开始, 惊喜的发现这里面多了一个方法, 叫做isUserAMonkey() 。

初看该方法, 不明白到底什么意思? " 判断用户是否是只猴子" ? 不可能吧..

于是好奇的我开始查看SDK。

文档上只写了 "Returns "true" if the user interface is currently being messed with by a monkey."

--> 如果当前UI正在被一只猴子瞎搞则返回 true .. ???

搞什么飞机? 什么意思?

于是好奇的我,又开始查看源码!

源码如下:

/** * Returns "true" if the user interface is currently being messed with * by a monkey. */ public static boolean isUserAMonkey() { try { return ActivityManagerNative.getDefault().isUserAMonkey(); } catch (RemoteException e) { } return false; }

继续,我又来到了ActivityManagerNative 类中。

public boolean isUserAMonkey() throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); mRemote.transact(IS_USER_A_MONKEY_TRANSACTION, data, reply, 0); reply.readException(); boolean res = reply.readInt() != 0; data.recycle(); reply.recycle(); return res; }

明天再看.. 哈哈.. 撤了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值