http://developer.android.com/reference/android/app/Activity.html#getParent%28%29 

I probably didn't need to include this check since the activity is not an embedded child, but it doesn't hurt.