Filed Under #java
The following trick actually works for any Java interface, Android or otherwise, but I find this to be particularly painful in animation-heavy Android applications, so I'm going to be using the AnimationListener interface as an example.
There's three common methods of creating a String with the appropriate user ID in place, namely direct string concatenation, using a StringBuilder, or using String.format. I personally find using the String.format method to be the cleanest and tend to use it when applicable, but I recently began wondering how it actually performs against the other two methods.
XOR encryption (or Exclusive-OR encryption) is a common method of encrypting text into a format that cannot be trivially cracked by the average person. XOR encryption is great for storing things like game save data, and other data types that are stored locally on a users computer, that while not a big deal if they are tampered with, you would like to deter people from doing so. XOR encryption is also used often as a part of more complex encryption algorithms.
Amazon recommends using a properties file to supply AWS credentials to your Java application, and while this is generally the most appropriate way to do it, what happens if you want to dynamically connect to different AWS accounts, or for whatever reason you need to provide the credentials in code?
Recently I was parsing a REST API that returned data in JSON format, and noticed that this particular API formatted it's dates in a peculiar way:
A lot of times when using a REST API, it is effective to map integers from your JSON to an enum in your Java models. With Google's GSON library, the process of doing this is can be a little tricky, but I find it well worth the added effort to do so.