title: Cant refresh data in ListFragment
body: <p>I am trying to implement a ListFragment with AsynchTaskLoader that contains datasource but I have trouble in refreshing listFragment as it doesnt get refresh when I change data from background in my BaseAsyncTaskLoader</p>
  
  <p>The code is attached:</p>
  
  <p><strong>The Activity that loads listfragment</strong></p>
  
  <pre><code>public class BaseFragmentManager extends FragmentActivity implements ListItemSelectedListener {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.fragment_stack);
  
          Button btnLoadMore = (Button) findViewById(R.id.new_fragment);
          btnLoadMore.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  Intent i = new Intent();
                  i.setAction("com.test.gcc.myintent.loader.BaseAsyncTaskLoader");
                  i.putExtra("action", "loadmore");
                  sendBroadcast(i);
              }
          });
  
          BaseListFragmentActivity fragment = new BaseListFragmentActivity();
           FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
           transaction.replace(R.id.fragment_container, fragment);
           transaction.addToBackStack(null);
           transaction.commit();
      }
  
      @Override
      public void onListItemSelected(int index) {
          Log.i("Error", "itemSelected-"+index);
      }
  
  }
  </code></pre>
  
  <p><strong>My LISTFragment class that is not being refreshed</strong></p>
  
  <pre><code>public class BaseListFragmentActivity extends ListFragment implements LoaderManager.LoaderCallbacks&lt;ArrayList&lt;MyData&gt;&gt; {
      private ListItemSelectedListener selectedListener;
      private int index = 0;
      private ArrayList&lt;MyData&gt; data;
      private BaseAsyncTaskLoader astask;
      private CustomListAdapter adapter;
  
  
      @Override public void onActivityCreated(Bundle savedInstanceState) {
          super.onActivityCreated(savedInstanceState);
          this.data = MyDataBroker.getDefaultBroker().getData();
  
          this.adapter = new CustomListAdapter(this.getActivity(), data);
  
          setListAdapter(this.adapter);
          setListShown(false);
          getLoaderManager().initLoader(0, null, this);
      }
  
      @Override
      public void onAttach(Activity activity) {
          super.onAttach(activity);
      }
  
      @Override public Loader&lt;ArrayList&lt;MyData&gt;&gt;  onCreateLoader(int id, Bundle args) {
  
          // This is called when a new Loader needs to be created.  This
          // sample only has one Loader with no arguments, so it is simple.
          astask = new BaseAsyncTaskLoader(this.getActivity());//new AppListLoader(getActivity());
          return astask;
      }
  
  
      @Override
      public void onLoadFinished(Loader&lt;ArrayList&lt;MyData&gt;&gt; Loader, ArrayList&lt;MyData&gt; data) {
          this.adapter.setData(data);
  
           if (isResumed()) {
                  setListShown(true);
              } else {
                  setListShownNoAnimation(true);
           }
      }
  
      @Override
      public void onListItemClick(ListView l, View v, int position, long id) {
          index = position;
          selectedListener.onListItemSelected(position);
      }
  
  
      @Override
      public void onLoaderReset(Loader&lt;ArrayList&lt;MyData&gt;&gt; data) {
          adapter.setData(null);
      }
  
      public interface ListItemSelectedListener {
          public void onListItemSelected(int index);
      }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>AsynchTaskLoader Class</strong></p>
  
  <pre><code>public class BaseAsyncTaskLoader extends AsyncTaskLoader&lt;ArrayList&lt;MyData&gt;&gt; {
      private ArrayList&lt;MyData&gt; data;
      private int pageNumber;
      private boolean listenerIsRegistered = false;
      private com.test.gcc.myintent.test.BaseAsyncTaskLoader.CustomBroadCastListener listener;
  
      public BaseAsyncTaskLoader(Context context) {
          super(context);
          pageNumber = 1;
  
          listener = new CustomBroadCastListener(); 
          if (!listenerIsRegistered) {
              context.registerReceiver(listener, new IntentFilter("com.test.gcc.myintent.loader.BaseAsyncTaskLoader"));
              listenerIsRegistered = true;
          }
      }
  
      /**
       * This is where the bulk of our work is done. This function is called in a
       * background thread and should generate a new set of data to be published
       * by the loader.
       */
      @Override
      public ArrayList&lt;MyData&gt; loadInBackground() {
          final Context context = getContext();
  
          return this.loadInBackgroud();
  
      }
  
      private ArrayList&lt;MyData&gt; loadInBackgroud() {
  
          return MyDataBroker.getDefaultBroker().getData(); //returns some data of custom type.
      }
  
      /**
       * Called when there is new data to deliver to the client. The super class
       * will take care of delivering it; the implementation here just adds a
       * little more logic.
       */
      @Override
      public void deliverResult(ArrayList&lt;MyData&gt; data) {
          if (isReset()) {
              if (data != null) {
                  onReleaseResources(data);
              }
          }
  
          if (isStarted()) {
              super.deliverResult(data);
          }
      }
  
      /**
       * Handles a request to start the Loader.
       */
      @Override
      protected void onStartLoading() {
          if (this.data != null) {
              deliverResult(this.data);
          }
  
          if (takeContentChanged() || this.data == null) {
              forceLoad();
          }
      }
  
      /**
       * Handles a request to stop the Loader.
       */
      @Override
      protected void onStopLoading() {
          // Attempt to cancel the current load task if possible.
          cancelLoad();
      }
  
      /**
       * Handles a request to cancel a load.
       */
      @Override
      public void onCanceled(ArrayList&lt;MyData&gt; data) {
          super.onCanceled(data);
          onReleaseResources(data);
      }
  
      /**
       * Handles a request to completely reset the Loader.
       */
      @Override
      protected void onReset() {
          super.onReset();
          onStopLoading();
          this.data = null;
      }
  
      public void onLoadMore(){
          this.loadInBackground();
      } 
  
  
      protected class CustomBroadCastListener extends BroadcastReceiver {
  
          @Override
          public void onReceive(Context context, Intent intent) {
              if (intent.getAction().equals("com.test.gcc.myintent.loader.BaseAsyncTaskLoader")) {
                  if(intent.getStringExtra("action") != null &amp;&amp; 
                          intent.getStringExtra("action").equals("loadmore")){
                      loadInBackground();
  
                  }
              }
          }
      }
  
  
      /**
       * Helper function to take care of releasing resources associated with an
       * actively loaded data set.
       */
      protected void onReleaseResources(List&lt;MyData&gt; apps) {      
          //NOTUSED
      }
  }
  </code></pre>
  
  <p>From debug I can see that the data is being loaded but the listFragment doesn't refresh and as far I know we don't have to refresh listFragment manually as it is attached to data source it should be refreshed automatically.</p>