Created
September 21, 2016 13:48
-
-
Save kingargyle/65f42ee1c4be4dee816115d6c68e809c to your computer and use it in GitHub Desktop.
Retrieve an Activity from a ContextWrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Activity getActivity() { | |
Context context = getContext(); | |
while (context instanceof ContextWrapper) { | |
if (context instanceof Activity) { | |
return (Activity)context; | |
} | |
context = ((ContextWrapper)context).getBaseContext(); | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment