I create an application with lots of fragments . In my last fragment I try to print something on LogCat
after 10 seconds . But it dosen't work for me .
This is my Fragment
class
public class StepTwentyTwoFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.step22_fragment, container, false);
testMethod();
return v;
}
public static StepTwentyTwoFragment newInstance() {
StepTwentyTwoFragment f = new StepTwentyTwoFragment();
Bundle b = new Bundle();
f.setArguments(b);
return f;
}
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if(isVisibleToUser) {
Activity a = getActivity();
if(a != null) a.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
}
public void testMethod(){
SystemClock.sleep(10000);
Log.d("PPP : ","456");
}
}
Actually I want print this "PPP" after 10 seconds when last fragment is launched. But it begins to print with the loading of some fragments in the application.
Have any ideas about this ?
Thank you.