Android's Log.wtf Method
developer.android.com
developer.android.com
public static boolean isUserAMonkey()
Returns "true" if the user interface is currently being messed with by a monkey.
http://developer.android.com/reference/android/app/ActivityM...Bill Atkinson came up with the idea of defining a system flag called "MonkeyLives" (pronounced with a short "i" but often mispronounced with a long one), that indicated when the Monkey was running. The flag allowed MacPaint and other applications to test for the presence of the Monkey and disable the quit command while it was running, as well as other areas they wanted the Monkey to avoid. This allowed the Monkey to run all night, or even longer, driving the application through every possible situation.
And then there are gems like WiFiManager.getScanResults(), which according to the docs returns a List<ScanResult>. Except that it's actually implemented as
try { return [do native call]; } catch (RemoteException ex) { return null; }.
So actually it returns a list except sometimes it returns null, which I have seen happen and it caused my app to force-close. There's shit like this all over the place. No wonder so many apps crash on random devices.So now any time I want to call a piece of the Android API I haven't worked with before I have to go find the source to make sure it's not doing something unexpected because I can't trust these Google monkeys to properly document their stuff. Sigh.
You'd be able to implement that as a Maybe [WifiResult], maybe Just a list of wifiresults or maybe Nothing, copying directly, but you'd probably want to have your datatype be Either String [WifiResult], either you get on the Left an error string or on the Right the list of wifiresults.
This is not something inherently unique to Haskell. Any strictly typed language could easily have chosen to not let null be a member of all classes. Or at the very least add some "non-nullable" qualifier to types.
Google should check it all, every release.
What is the problem with Looper? Looking at Looper.java and MessageQueue.java, the code is ugly but the only questionable parts seem to be MessageQueue's recycling of Message objects..
http://www.netmite.com/android/mydroid/donut/frameworks/base...
http://www.netmite.com/android/mydroid/donut/frameworks/base...
Then there's the way in which the constructor of the Handler class will automatically attach to the 'current' looper thread. If the current thread is not a looper, it will throw a RuntimeException. It would probably be appropriate here to create one's own Exception class rather than throw a generic one both for readability of the stacktrace and so you can catch it explicitly. To me is just another example of amateuristic/lazy software engineering and lack of understanding of general Java principles. Either way, this automatic association is not explained in the documentation of Looper, they just give the example and you're supposed to understand what's happening. I don't see what would be wrong with just creating a Handler and attaching it to the looper thread explicitly, if not just for readability's sake. My main gripe here is the lack of documentation, as if they really don't give a crap about whether or not you understand what you're doing, as long as you're copy/pasting their example you should be fine.
The naming is confusing. What the fuck is a 'Looper'? This name only makes sense if you're coming from C and I guess I'm old enough to get it, but come on people, there must be more descriptive names than that. Why am I posting messages to the Handler object? Isn't the looper thread supposed to post messages to the handler, which then 'handles' them? Do you post an event to an event handler? Why can't the functionality of Looper and Handler just be in one class? What's the use of the CallBack interface, if I can just extend Handler? In both cases I need to implement only a single method, so what's the point?
According to the docs this is the functionality of the Handler class:
There are two main uses for a Handler: (1) to schedule messages and runnables to be executed as some point in the future; and (2) to enqueue an action to be performed on a different thread than your own.
Here's how Swing lets you do stuff in Swing's main UI thread: EventQueue.invokeLater( [your Runnable goes here] );
Here's how you run something in a separate thread using executors: executor.execute( [your Runnable goes here] );
This is how you schedule something that is supposed to run in the future: executor.schedule( [your Runnable goes here], 1000L, TimeUnit.MILLISECONDS );he was talking about documentation.
android.glitz
http://groups.google.com/group/android-developers/browse_thr...
What a Terrible Failure
adb lolcat was another andoid easter egg that made me laughoops, didnt mean to interrupt the cute fest with actual question. fucking morons.