Hi Friends, if you like my blog please give your valuable comments it will help to improve my blog content and enthusiasm to write a lot in android World.

Friday, April 4, 2014

Android - How to Get activity from context

Sometimes we pass context of an activity as a parameter to some other function and later we might want the activity too. So instead of passing the activity also to that function, we can get the activity from context itself.

You can get the activity from the context by type casting the context to activity.

Activity activity = (Activity) _context;