Opening and Closing Menu Programmatically
API for opening menu programmatically is openOptionsMenu(). If we are in a different context, then we can use this method by,
((Activity) mContext).openOptionsMenu();
For closing menu programmatically, if it opens use this,
((Activity) mContext).closeOptionsMenu();
((Activity) mContext).openOptionsMenu();
For closing menu programmatically, if it opens use this,
((Activity) mContext).closeOptionsMenu();