I didn't really look into what the onBackPressed code is doing, but it won't get executed if the user hits the home button or navigates away from the app via a phone call or a notification.  Not sure if that's a problem or not.  Maybe onPause() would work?