title: fragment is already active while calling Fragment.setArguments()
body: <p>I am creating an activity which shows a list of videos(VideoListingActivity) depending on the parameters passed from the parent activity.my I am trying to pass the bundle passed to VideoListingActivity to its child fragment so that it can fetch the related data from database and display it on the activity. I am trying to use Fragment.setArguments() to pass the bundle to fragment but getting the below error .</p>
  
  <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rrdtech.vidyavaan.android/com.rrdtech.vidyavaan.android.VideoListingActivity}: java.lang.IllegalStateException: Fragment already active
  </code></pre>
  
  <p>I think the fragment is attached to activity post to onCreate() so should this error even be raised ?</p>
  
  <p>Below are the codes for my activity and fragment </p>
  
  <p>VideoListingActivity.java</p>
  
  <pre><code> public class VideoListingActivity extends ActionBarActivity   implements   FilterFragment.OnFilterItemSelectedListener,
      android.support.v7.widget.SearchView.OnQueryTextListener
  {
  
   public VideoListFragment videoListFragment;
   private android.support.v7.widget.SearchView searchView;
   private  Context context;
  private Bundle bundle;
  private String listBy;
  private String subjectId;
  private String levelType;
  private FragmentTransaction ft;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_video_listing);
  
     // videoListFragment=new VideoListFragment();
      videoListFragment= (VideoListFragment) getFragmentManager().findFragmentById(R.id.frg_video_listing_video_listing_fragment);
       ft =getFragmentManager().beginTransaction();
      context=this;
      bundle = new Bundle();
      bundle = getIntent().getExtras();
      videoListFragment.setArguments(bundle);
  
  }
  
  @Override
  protected void onStart() {
      super.onStart();
  
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.menu_video_listing, menu);
      MenuItem menuItem=menu.findItem(R.id.item_action_search);
  
      //SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
       searchView = (android.support.v7.widget.SearchView) menu.findItem(R.id.item_action_search).getActionView();
      setupSearchView(menuItem);
      //searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
  
      return super.onCreateOptionsMenu(menu);
  }
  
  public  void setupSearchView(MenuItem searchItem)
  {
  
      SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
      if(searchManager != null)
      {
          SearchableInfo info = searchManager.getSearchableInfo(getComponentName());
          searchView.setSearchableInfo(info);
      }
      searchView.setOnQueryTextListener(this);
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
  
      //noinspection SimplifiableIfStatement
      if (id == R.id.action_settings) {
          return true;
      }
  
      return super.onOptionsItemSelected(item);
  }
  
  
  @Override
  public void onFilterItemSelected(String filterId) {
      videoListFragment.filterSelectedAction("filter id is "+filterId);
  }
  
  @Override
  public boolean onQueryTextSubmit(String query) {
      CommonFunctions commonFunctions = new CommonFunctions();
      commonFunctions.showProgressDialog(context,"getting data","bringing");
  
      ft.replace(R.id.frg_video_listing_filter_fragment,videoListFragment);
      ft.commit();
      commonFunctions.dismissProgressDialog();
      return false;
  }
  
  @Override
  public boolean onQueryTextChange(String newText) {
      return false;
  }
  }
  </code></pre>
  
  <p>VideoListingFragment.java</p>
  
  <pre><code>public class VideoListFragment extends Fragment {
  
  private ListView videoListView;
  private Context activityContext;
  private VideosListAdapter listAdapter;
  private List&lt;Video&gt; videosList;
  private  Bundle b;
  private String listBy;
  private String subjectId;
  private String levelType;
  
  @Override
  public void onAttach(Activity activity) {
      super.onAttach(activity);
      activityContext = activity.getApplicationContext();
      b=new Bundle();
  }
  
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      return inflater.inflate(R.layout.video_list_fragment,container,false);
  
  
  }
  
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
  
      b= getArguments();
      listBy = b.getString(VidyavaanGlobal.listBy);
      Log.d("list by ",listBy);
  }
  
  @Override
  public void onStart() {
      super.onStart();
  }
  
  
  public void filterSelectedAction(String x)
  {
      Log.d("passed is ", x);
  }
  
  public void fillData()
  {
      videosList.add(new Video("chapter1","title1", "pragyan public school", "pawan saraskar", "Chemistry", "Advance", "abcd url", "21", "5/6/2015", "thumbnail url"));
      videosList.add(new Video("chapter2","title2","pragyan public school","pawan saraskar","physics","Advance","abcd url","21","5/6/2015","thumbnail url"));
      videosList.add(new Video("chapter3","title3","pragyan public school","pawan saraskar","english","Advance","abcd url","21","5/6/2015","thumbnail url"));
      videosList.add(new Video("chapter4","title4","pragyan public school","pawan saraskar","Chemistry","Advance","abcd url","21","5/6/2015","thumbnail url"));
      videosList.add(new Video("chapter5","title5","pragyan public school","pawan saraskar","Chemistry","Advance","abcd url","21","5/6/2015","thumbnail url"));
      videosList.add(new Video("chapter6","title6","pragyan public school","pawan saraskar","Chemistry","Advance","abcd url","21","5/6/2015","thumbnail url"));
      videosList.add(new Video("chapter7", "title7", "pragyan public school", "pawan saraskar", "Chemistry", "Advance", "abcd url", "21", "5/6/2015", "thumbnail url"));
  }
  
  
  public void displayVideoList(boolean searchReqeust )
  {
  
  }
  
  public void displayVideoList(String pListBy, String pValue)
  
  {
  
  
  
      listAdapter = new VideosListAdapter(activityContext,videosList);
      videoListView.setAdapter(listAdapter);
  }
  
  public void displayVideoList(String subjectId, String videoType, String VideoLevel)
  {
  
  }
  
  
  }
  </code></pre>
  
  <p>can one please help. Thanks in advance.</p>