Simpler Android APIs with AutoParcel
Simpler Android APIs with AutoParcel
I have made a small change to one of the Android libraries I maintain and was quite happy with how it turned out, so I wanted to write a few words about it.
Strings! Strings everywhere!
One of the things I like the least about the Android framework is its tendency to use Strings in all the wrong places. Java already has a (rightfully) terrible reputation for its type system. The Android SDK, however, goes a step further by forcing people to serialize their well-typed data structures and handing back nothing but a String in return. If you’ve ever accidentally called IntentgetStringExtra
on an Integer you’ll know what I’m talking about. There is nothing preventing you from doing this at compile time. The only mitigation is manual careful checks that you’ve passed the corresponding constants on both sides of the serialization boundary.