Is it possible to start an activity from a regular java class?
- by Yotam
In my ActionBarSherlock I have the same menu items for all activities, so it seems unwise to
define onClick handlers in each activity - they all do the same.
Instead I created a class called MyClickListener that implements com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener, and in there I have a simple switch block that starts the appropriate activity.
Problem is that Intent constructor's first argument is of type Context, and even when I pass this to MyClickListener's constructor, I can't start any activity.
The same goes for every method that has a Context object as a parameter.
Is there a way to work around it?
What is a context object?
Thanks