Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save iniyanmurugavel/92a04a87caf09ffc18f4eb53ccacf4a1 to your computer and use it in GitHub Desktop.
Save iniyanmurugavel/92a04a87caf09ffc18f4eb53ccacf4a1 to your computer and use it in GitHub Desktop.
Context instead of Activity
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