Following up on the Intent theme from the previous post, here’s another tidbit about Intents: apparently you cannot reliably tell where an Intent is being sent from.
Android Jittery Scrolling Gallery
Recently I had a problem with an Android app in which I used a Gallery to scroll horizontally between some items. It worked pretty well, but all of a sudden, without changing the Gallery code at all, it started to jitter weirdly when I scrolled the Gallery.
To be more precise, when I touched the Gallery and slowly dragged my finger to the side, the items would at first follow my finger, only to jump back to their original position. And the moment I moved my finger again, they would follow the gesture again.
If you’ve seen this behaviour in your own code, the following may help.
Encryption on Android & BouncyCastle
If you’ve tried to encrypt stuff in an Android app, you may have noticed that not all phones support all encryption algorithms. And that’s particularly sad when the algorithm in question is AES, the Advanced Encryption Standard. So what do you do? You do what every good Java programmer does, and head for the Bouncy Castle.
ContentProvider Curses Cursor
If you’ve developed Android apps, chances are you’ve written some Activity that displays a list of stuff. If you’ve done that, chances are, you’ve filled the list with data from a database cursor. If you’ve done that, chances are you created the Cursor by querying a content URI, which in turn invokes a ContentProvider.
So how do you handle errors with that?
To put that question into context, let’s look at some common things to check on a Cursor variable, and what they mean semantically:
- When calling a function that returns a Cursor (such as database query functions), the return value could be
null. That signals an unspecified error on the part of the function. - The Cursor object may have a row count of zero. Does that mean there was an error fetching data, or does it mean the data set is empty? Two different things.
- The function may throw an exception instead of returning a Cursor. That’s pretty cool, but Cursors are often used in conjunction with a ContentProvider, which may or may not run in the same process as the calling code. As yet Android is unable to propagate exceptions across processes.
In other words, as cool as it might be to use Cursors as the standard data interface for filling lists of stuff with, well, stuff, their interface really doesn’t lend itself to good error handling. And good error handling is at the root of stable software.


