I written separate class of adapter for gridview present in fragment. If a called windowmanger first time from adapter constructor it worked but if i changed orientation windowmanager becomes null.
I written code for getting window manager like
public CalendarAdapter(Context c, Calendar monthCalendar) {
getWindowDimension();
}
void getWindowDimension() {
Display display = (((Activity)mContext).getWindowManager().getDefaultDisplay());
windowHeight = display.getHeight();
windowWidth = display.getWidth();
}
Even tried with getSystemService(WINDOW_SERVICE)
I think problem is because of activity recreation. Its not getting window of the activity if its not created. Throws Nullpointer exception for window manager.
In manifest activity has this flags :
android:configChanges="orientation|screenLayout|navigation|layoutDirection"
Please help for same.