标签云

微信群

扫码加入我们

WeChat QR Code

I was looking at the new APIs introduced in Android 4.2.While looking at the UserManager class I came across the following method:public boolean isUserAGoat()Used to determine whether the user making this call is subject to teleportations.Returns whether the user making this call is a goat.How and when should this be used?


Martindale: None of what you said is true; it wasn't an incident, it isn't internal and it's not a memory management technique. Consult its code instead of making assumptions... :)

2019年08月19日22分57秒

This might be related to when Google use goats as a mower in their Mountain View Headquarters.

2019年08月19日22分57秒

There are also constants for the gravity on the first death star developer.android.com/reference/android/hardware/… and on the island of the tv show Lost developer.android.com/reference/android/hardware/… which is of course, the numbers.

2019年08月19日22分57秒

It seems clear by the Javadocs that the proper use case for this method arises when you need to know whether the user making the call is subject to teleportations.What could be more clear?

2019年08月19日22分57秒

They even updated the documentation after Lollipop: "As of LOLLIPOP, this method can now automatically identify goats using advanced goat recognition technology."

2019年08月20日22分57秒

Theory: Goats are found in all kinds of precarious places, like sheer cliffs, possibly bucking location trends they get from regular non-goat users. Might explain "teleportations", which could be goats appearing to wildly relocate as the software tries to determine their location with algos designed for non-goats.

2019年08月19日22分57秒

#define false random() % 2 but this isn't Java...

2019年08月19日22分57秒

This is a history lesson, not an answer.Even if it is an Easter egg, is there a valid use case for it?Being an Easter egg doesn't preclude it from being useful, and you've not shown whether it is or is not useful.

2019年08月19日22分57秒

That's a real app.

2019年08月19日22分57秒

I feel bad for anyone who cheekily used this function, expecting it to return false forever.

2019年08月19日22分57秒

have you tried if(false) {statement;} ?

2019年08月19日22分57秒

if (Boolean.FALSE) { ... } usually seems to work.

2019年08月19日22分57秒

djechlin I do not know if this is android only, in standard java ` if(false){...}` compiles just fine (open jdk javac 1.6 and 1.7)

2019年08月19日22分57秒

PeterOlson - if you are specifically trying to test a code branch where an if goes false or true, this is the most precise and obvious way to simulate that - commenting out the block could be less accurate if you don't match to the proper end of the block (perhaps you didn't notice a discreet if/else block immediately following), it will lead to a compile error if you're forcing to the following else block, etc.

2019年08月19日22分57秒

"provided the implementation doesn't change" - and there's the problem. This is a disastrous way to implement a warning-free "if (false)" because the implementation can and does change. See my answer to this question: as of API21 isUserAGoat() returns true if a user has a specific app installed. Good luck diagnosing that when your code suddenly starts behaving oddly on "random" devices!

2019年08月19日22分57秒

i don't have it, where do you right click? or what it is used for

2019年08月19日22分57秒

auselen You have to right click on a column title in order to see the drop down menu to add the Goats Teleported column (at least that's how it works in Chrome on OS X). cl.ly/Ksbd

2019年08月19日22分57秒

Windows XP + latest Chrome = it isn't there, on Ubuntu I see it.

2019年08月19日22分57秒

Windows 7 running Chrome latest doe not show it either. :/

2019年08月19日22分57秒

It's likely that the inside joke has it's origins here: googleblog.blogspot.be/2010/04/goats-are-baaaahk.html

2019年08月19日22分57秒

If you are writing "dummy" code just to quickly test something, what is the problem with an Eclipse warning?? I think this is actually great as you can find it in case you've forgotten

2019年08月20日22分57秒

Tomasz the problem is that, in Eclipse, the warning mark clutters the breakpoint, and you have to open the breakpoint view to either deactivate or remove it

2019年08月19日22分57秒

Yeah, I have a solution for that. You can right click on the warning symbol and select "Toggle Breakpoint". If the following line/option is enabled it means the breakpoint is created. My point was, dummy code is bad and it should be a warning so yo don't forget ;)

2019年08月19日22分57秒

Tomasz The problem with that solution is that you have know beforehand where the breakpoint is, so a simple visual inspection won't let you know that the warning hides a breakpoint, an even better solution though, is to use conditional breakpoints, with them you can forget about dummy code (and convention methods) altogether, but those differ between IDE's and can't be automatically shared among workstations

2019年08月19日22分57秒

Why not just use a null statement ;? I mean, goats are clearly better, but there is an easy way around this already

2019年08月19日22分57秒

"There's a funny named method/constant/whatever in each version of Android." Could you name some?

2019年08月19日22分57秒

For example, there are a nivel of log called Log.wtf that they call What a Terrible Failure :P

2019年08月19日22分57秒

A bit like Delphi's EProgrammerNotFound? stackoverflow.com/questions/2084120/…

2019年08月19日22分57秒

HoneyComb is AdapterViewAnimator#fyiWillBeAdvancedByHostKThx()

2019年08月19日22分57秒

Angelo.Hannes, In the Sensor Constants for Gravity there's one for Death Star (Star Wars)

2019年08月19日22分57秒

ibm is also rumored to have goat references throughout various internal software.

2019年08月19日22分57秒

Archived link for the "Mowing with goats" reference : web.archive.org/web/20100619024942/https://…

2019年08月19日22分57秒

Why would anyone ever put any kind of if(false) in production? Come on here. If that's what your code looks like then this implementation changing is the least of your problems.

2019年08月19日22分57秒

Well, as per the actual API documentation (user teleportation tendencies), I think using it to always return false is really the only way to follow the contract.Still, you bring up a good point.

2019年08月19日22分57秒

The goat simulator looks awesome on google play play.google.com/store/apps/…. It would be good to know what one can gain from being a goat.

2019年08月19日22分57秒

My assumption with this one is it allows the ActivityManager to report if it has been invoked by the monkey ui stress testing tool, but i have never confirmed this.

2019年08月19日22分57秒

Can't seem to find it anymore :(

2019年08月19日22分57秒

The method was created before the goat simulator. Although it checks if the app is installed now, it didn't do anything before. And it's a joke anyway.

2019年08月19日22分57秒