title: Get fragment content from baseactivity
body: <p>My app always use the same menu, so I had defines a BaseActivity, and each activity extends now BaseActivity.</p>
  
  <p>The thing is one element of the menu is used to synchronize system. So depending of the activity I'm in, it should refresh different elements : listview, map, etc...</p>
  
  <p>I'm able to know which activity is on top using SharedPreference on onStartMethod.</p>
  
  <p>But from my BaseActivity, I'm unable to retrieves sub- Activities and fragments inside them.</p>
  
  <p>I have : </p>
  
  <pre><code>public class FragmentTabsPdv extends BaseActivity
  </code></pre>
  
  <p>Inside FragmentTabsPdv, I have a Sherlock Tab, with 2 fragment :</p>
  
  <pre><code>ListPdvTabFragment extends SherlockFragment  
  MapPdvTabFragment extends SherlockFragment
  </code></pre>
  
  <p>Inside ListPdvTabFragment, I want to refresh my ListView, but I don't know how to reach it from BaseActivity.</p>
  
  <p>Of course, my menu is defines in BaseActivity:</p>
  
  <p>The synchronize menu start a AsyncTask who get new content from server, and update sqlite db.
  and the end of the process onPostExecute, I need to update my elements : </p>
  
  <pre><code> @Override
  protected void onPostExecute(Void result) {
      super.onPostExecute(result);
      if (lTiendas == null){
          Toast.makeText(ctx, "Hubo un error al sincronizar los datos, intentalo más tarde", Toast.LENGTH_LONG).show();
      }
  
      if (BaseActivity.refreshItem != null) {
          String frontActivity = prefs.getString("FrontActivity", "");
          if (!frontActivity.isEmpty()){
              if (frontActivity.equals("ListPdvTabFragment")){
                  // get List to Refresh 
              }
          }
  
  
          BaseActivity.completeRefresh();
      } else {
  
          Intent i = new Intent(ctx, DashBoard.class);
          i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          ctx.startActivity(i);
  
          if ((SplashScreen) ctx != null)
              ((SplashScreen) ctx).finish();
      }
  
  }
  </code></pre>
  
  <p>Tab Activity : </p>
  
  <pre><code>public class FragmentTabsPdv extends BaseActivity {
  private ArrayList&lt;Pdv&gt; listaPdv;
  private Usuario mUser;
  private SharedPreferences prefs;
  private Context ctx;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      ctx = this;
      getSupportActionBar().setDisplayHomeAsUpEnabled(true);
      prefs = PreferenceManager.getDefaultSharedPreferences(this);
  
      DatabaseHandlerTienda db = new DatabaseHandlerTienda(this);
      // listaPdv = (ArrayList&lt;Pdv&gt;) db.getAllTiendas();
      String jsonUser = prefs.getString("usuario", "");
      Gson gson = new Gson();
      mUser = gson.fromJson(jsonUser, Usuario.class);
      listaPdv = db.getAllTiendas();
  
      ActionBar actionBar = getSupportActionBar();
      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
      ActionBar.Tab tab1 = actionBar.newTab();
      tab1.setText("Lista");
      tab1.setIcon(R.drawable.ic_action_view_as_list);
  
      ActionBar.Tab tab2 = getSupportActionBar().newTab();
      tab2.setText("Mapa");
      tab2.setIcon(R.drawable.ic_action_location_map);
  
      // create the two fragments we want to use for display content
  
      tab1.setTabListener(new TabListener&lt;ListPdvTabFragment&gt;(this, "lista", ListPdvTabFragment.class));
      tab2.setTabListener(new TabListener&lt;MapPdvTabFragment&gt;(this, "mapa", MapPdvTabFragment.class));
  
      actionBar.addTab(tab1);
      actionBar.addTab(tab2);
  }
  
  public ArrayList&lt;Pdv&gt; getListaPdv() {
      return listaPdv;
  }
  
  public void setListaPdv(ArrayList&lt;Pdv&gt; listaPdv) {
      this.listaPdv = listaPdv;
  }
  
  public static class TabListener&lt;T extends Fragment&gt; implements ActionBar.TabListener {
      private Fragment mFragment;
      private final Activity mActivity;
      private final String mTag;
      private final Class&lt;T&gt; mClass;
  
      /**
       * Constructor used each time a new tab is created.
       * 
       * @param activity
       *            The host Activity, used to instantiate the fragment
       * @param tag
       *            The identifier tag for the fragment
       * @param clz
       *            The fragment's Class, used to instantiate the fragment
       */
      public TabListener(Activity activity, String tag, Class&lt;T&gt; clz) {
          mActivity = activity;
          mTag = tag;
          mClass = clz;
      }
  
      /* The following are each of the ActionBar.TabListener callbacks */
  
      public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
          // Check if the fragment is already initialized
          if (mFragment == null) {
              // If not, instantiate and add it to the activity
              mFragment = Fragment.instantiate(mActivity, mClass.getName());
              ft.add(android.R.id.content, mFragment, mTag);
          } else {
              // If it exists, simply attach it in order to show it
              // ft.attach(mFragment);
              ft.show(mFragment);
          }
      }
  
      public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
          if (mFragment != null) {
              // Detach the fragment, because another one is being attached
              // ft.detach(mFragment);
              ft.hide(mFragment); // Optimize map display
          }
      }
  
      public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
          // User selected the already selected tab. Usually do nothing.
      }
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      switch (item.getItemId()) {
      case android.R.id.home:
          NavUtils.navigateUpFromSameTask(this);
          return true;
      case R.id.menu_sync:
          DatabaseHandlerTienda db = new DatabaseHandlerTienda(this);
          ArrayList&lt;Pdv&gt; lTiendas = db.getAllTiendas();
  
          // adbTienda.notifyDataSetChanged();
          // Toast.makeText(getActivity(), "test", Toast.LENGTH_LONG).show();
          return true;
  
      default:
          return super.onOptionsItemSelected(item);
      }
  }
  
  @Override
  protected void refresh() {
      LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      ImageView iv = (ImageView) inflater.inflate(R.layout.refresh_action_view, null);
  
      Animation rotation = AnimationUtils.loadAnimation(this, R.anim.refresh);
      rotation.setRepeatCount(Animation.INFINITE);
      iv.startAnimation(rotation);
  
      refreshItem.setActionView(iv);
      // Sincronize:
  
      SyncData sd = new SyncData(ctx);
      sd.execute();
      // GET LISTVIEW FRAGMENT AND UPDATE VIEW
  }
  
  }
  </code></pre>