I noticed that my app only when is closed by system during open there is nullpointexception. Look I have Activity here I get data form db and create an object. Then I create new Fragment and set before created object to frament by setter. And use fragment manager to display fragment. Any here is a problem because in onCreate method field with my object is null. I am sure I seted object and it wasnt null.
Activity where I get data from db and create Fragment
public class ActivityForSingle extends AppCompatActivity {
Employee emloyee;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_for_single);
...
getEmployee(); // here I get emplyee from db and create employee object
SitePersonFragment f = new SitePersonFragment();
f.setEmpoyee(employee); // here emplyee is not null
getSupportFragmentManager().beginTransaction().add(R.id.frameForFragment, f, "USER_SITE").commit();
}
public class SitePersonFragment extends Fragment implements Update, DatePickerDialog.OnDateSetListener {
Employee employee;
setEmployee(Employee e){
this.emplyee = e;
//here e and employee is not null
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//here employee is null
// why??
}
What happend? I cannot debug because app is destroyed.