Created
October 15, 2020 05:02
-
-
Save iniyanmurugavel/92a04a87caf09ffc18f4eb53ccacf4a1 to your computer and use it in GitHub Desktop.
Context instead of Activity
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
public Activity getActivity(Context context) | |
{ | |
if (context == null) | |
{ | |
return null; | |
} | |
else if (context instanceof ContextWrapper) | |
{ | |
if (context instanceof Activity) | |
{ | |
return (Activity) context; | |
} | |
else | |
{ | |
return getActivity(((ContextWrapper) context).getBaseContext()); | |
} | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment