Current location - Recipe Complete Network - Complete cookbook of home-style dishes - What is the reason why it stops running when switching pages with fragments?
What is the reason why it stops running when switching pages with fragments?
Fragment is used in Android to switch pages. If the application stops running, the possible reasons are as follows:

The activity bound by Fragment has been destroyed, the program references activity, and the null pointer will exit unexpectedly.

After the fragment was created, there was no commit operation, which made it impossible to instantiate the fragment.

The solution is to use judgment when using activities, as shown below:

@ Overlay

Public? Invalid? onHiddenChanged(boolean? hidd)? {

What if? (! hidd? & amp& amp? getActivity()? ! =? null)? {

System.out.println ("Do you want to execute this method");

}

}