Communicating with a Server

Now that I've put together the server-based code, it's time to jump back into the mobile code, and start communicating. But before proceeding, I'd like to strongly emphasize a design point: If you do anything that "takes time" on a mobile device, don't do it on the main UI thread. I can't emphasize this enough. In fact, Android has introduced "StrictMode" to prevent you from doing this ( ).

For most consumer-based mobile development, I don't see many instances where the main thread is used for long tasks. But in a corporate environment, it can be tempting to assume you've got a fast connection, and - for reasons of code simplicity - execute everything in a single thread. Don't do it! :-)

One more point before getting started: This article will only pull public data from the server, and it won't attempt to use the Facebook credentials. I did this so that I can focus on the actual communication. Also, once I start sending credentials around, it's very, very important to ensure that I'm handling user data in a secure manner. If you take a casual approach to personal information (PI), you can cause serious harm to your company. Furthermore, many European countries have data privacy laws which impose penalties if you don't handle the information securely and carefully.

So with those two cautionary tales noted, I'll now proceed to update the iOS and Android code.