I have single activity App with a drawer menu
public class MainActivity extends ActionBarActivity {
....
void selectItem(int position) {
Bundle args = new Bundle();
args.putInt(PageFragment.ARG_Page_NUMBER, position);
android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();
android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
android.support.v4.app.Fragment fragment;
int ActiveFragmentId = 3;
if(position == 0 ){
fragment = new Fragment1();
} else if( position == 1){
fragment = new Fragment2();
}
}
....
and the two fragments Fragment1 and Fragment2 both have async task in them
Now if the Asnc Task in Fragment1 task is started(i.e. hold a break point on onBackground() of the async task in Fragment1 ) and if i switch to Fragment2
the Async Task in Fragment2 will not work until the onPostExceute() of Fragment1 is executed. why is that?
Also getActivity() == null, inside onPostExecute() of Fragmnet1's Async Task, while switching to Fragment2
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…