Added code from Android's Messaging application