Oct 11 2012

SQLite, Content Providers, & Thread Safety

A common source of confusion when implementing ContentProviders is that of thread-safety. We all know that any potentially expensive query should be asynchronous so as not to block the UI thread, but when, if ever, is it OK to make calls to the ContentProvider from multiple threads?

Sep 16 2012

Tutorial: AppListLoader (part 4)

This will be my fourth and final post on Loaders and the LoaderManager. Let me know in the comments if they have been helpful! Links to my previous Loader-related posts are given below:

Due to public demand, I’ve written a sample application that illustrates how to correctly implement a custom Loader. The application is named AppListLoader, and it is a simple demo application that queries and lists all installed applications on your Android device. The application is a modified, re-thought (and bug-free) extension of the LoaderCustom.java sample that is provided in the API Demos. The application uses an AppListLoader (a subclass of AsyncTaskLoader) to query its data, and the LoaderManager to manage the Loader across the Activity/Fragment lifecycle:

Aug 26 2012

Follow This Blog On Google Currents!

Hi all,

I’ve recently made this blog available on Google Currents! Install the application and subscribe by clicking this link.

If you have never used Google Currents, I strongly recommend that you try it out. It’s a really great way to keep up with the latest news, blogs, and your favorite Google+ streams, and it works seamlessly offline (which I’ve found is great for long plane rides). If you’re a long time Flipboard user, I recommend you give it a try as well… in my opinion, Currents is easier to navigate and feels much more like a native Android application. That said, I do tend to be a bit biased towards the native Google apps. :P

Aug 21 2012

Implementing Loaders (part 3)

This post introduces the Loader<D> class as well as custom Loader implementations. This is the third of a series of posts I will be writing on Loaders and the LoaderManager:

First things first, if you haven’t read my previous two posts, I suggest you do so before continuing further. Here is a very brief summary of what this blog has covered so far. Life Before Loaders (part 1) described the flaws of the pre-Honeycomb 3.0 API and its tendency to perform lengthy queries on the main UI thread. These UI-unfriendly APIs resulted in unresponsive applications and were the primary motivation for introducing the Loader and the LoaderManager in Android 3.0. Understanding the LoaderManager (part 2) introduced the LoaderManager class and its role in delivering asynchronously loaded data to the client. The LoaderManager manages its Loaders across the Activity/Fragment lifecycle and can retain loaded data across configuration changes.

Aug 7 2012

'Exit Application?' Dialogs Are Evil, Don't Use Them!

Here’s a question that is worth thinking about:

Should I implement an “Exit application?” dialog in my app?

In my experience, the answer is almost always no. Consider the official Flickr app, as an example. At the main screen, the user clicks the back button and is immediately prompted with a dialog, questioning whether or not the user wishes to exit the application:

+1 this blog!

Android Design Patterns is a website for developers who wish to better understand the Android application framework. The tutorials here emphasize proper code design and project maintainability.

Find a typo?

Submit a pull request! The code powering this site is open-source and available on GitHub. Corrections are appreciated and encouraged! Click here for instructions.

Apps by me

Shape Shifter simplifies the creation of AnimatedVectorDrawable path morphing animations. View on GitHub.
2048++ is hands down the cleanest, sleekest, most responsive 2048 app for Android!