Null Pointer Exception occurs at times randomly. Occurs mostly when pressed the backpressed from a particular fragment.
Exception occurs when tries to pass a param called "userregid" using Volley.
params.put("userregid", Utils.getString(((BaseActivity)getActivity()).get_hospital_userreg_id()));
I wrote a method in a BaseActivity to identify the hospital_userreg_id according to the conditions. This is the function ,
public int get_hospital_userreg_id() {
int userreg_id = 0;
switch (AppConst.HOSPITAL_CURRENT_ID) {
case 36:
userreg_id = AppConst.HOSP_ONE_USERREG_ID;
break;
case 37:
userreg_id = AppConst.HOSP_TWO_USERREG_ID;
break;
}
return userreg_id;
}
I feel that the issue is related to calling the function from the fragment. Any solutions ?