Last active
September 4, 2018 07:09
-
-
Save colinrtwhite/0cf8863a59f5d29c642bf99665908397 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
fun Context.toActivity(): Activity? { | |
var context = this | |
while (context is ContextWrapper) { | |
if (context is Activity) { | |
return context | |
} | |
context = context.baseContext | |
} | |
return null | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment