Question: I'm using viewPager to create a layout with tabs and in each tab I use a Fragment. One of them is to get all de user contacts and put it on a ListView. But I want to call de AssyncTask only if the Fragment is displayed on screen.

is there a method to do it?
TY

Answer: 
Start your AsyncTask in onStart which is the method called once the fragment becomes visible to the user. onCreateView will be called even if the fragment doesn't become visible.
See also: <http://developer.android.com/reference/android/app/Fragment.html#onStart()>

I would however recommend to use a loader instead of AsyncTask (e.g. an AsyncTaskLoader <http://developer.android.com/reference/android/content/AsyncTaskLoader.html>).
You can check to see if it's visible with `.isVisible()` something like this 

```
MyFragmentClass fragment = (MyFragmentClass) getSupportFragmentManager().findFragmentByTag("fragmentTAG");

if (fragment != null && fragment.isVisible()) {
     // call AsyncTask
}

```