I was wondering, during activity re-creation, or fragment re-creation or service re-creation, is there a possibility, that the same instance of class being re-used?
For example
//public class HomeFragment extends Activity {
//public class HomeFragment extends Service {
public class HomeFragment extends Fragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Can instrumentSearchMonitor has possibility to become null right here, due to onDestroy?
instrumentSearchMonitor.doSomething();
}
@Override
public void onDestroy() {
super.onDestroy();
instrumentSearchMonitor = null;
}
private InstrumentSearchMonitor instrumentSearchMonitor = new InstrumentSearchMonitor();
}
For the above case, is there a possibility that onCreate
will encounter a null object, due to nullify action in onDestroy
?
My testing is, after onDestroy
is being called, the next call of onCreate
will happen on the different class instance.
I was wondering, is there any possibility, that the next call of onCreate
, will happen on the same class instance?