A few more changes from commit() to commitAllowingStateLoss() which fixes the state exception. Only try to open a note if the activity is still running.