@Override
  public void onResume() {
    Log.d(LOG_NAME, "onResume");
    super.onResume();

    theFinder.init();

    if (theAdapter == null) {
      theAdapter = new BookmarkAdapter(this);
      this.setListAdapter(theAdapter);
    }

    for (final BaseAgency anAgency : TheApp.theAgencies.values()) {
      anAgency.init(this);
    }

    theAdapter.clear();

    theDB = new BookmarksDataHelper(this);
    ArrayList<Bookmark> theBookmarks = theDB.getAllBookmarks();
    for (Bookmark aBookmark : theBookmarks) {
      theIntents.put(aBookmark, aBookmark.getTheIntent());
      theAdapter.add(aBookmark);
    }

    startLocationSearch();
    killRotateTimer();
    killRefreshPredictionTimer();

    setupRotateTimer();
    setupRefreshPredictionTimer();
  }
 protected void startLocationSearch() {
   if (lastLocationUpdate
       < (System.currentTimeMillis() - (TheApp.getPredictionRefreshDelay() / 2))) {
     if (theFinder.startLocationSearch()) {
       if (theProgressDialog != null) {
         theProgressDialog.dismiss();
       }
       theProgressDialog = new ProgressDialog(this);
       theProgressDialog.setCancelable(true);
       theProgressDialog.setMessage(TheApp.getResString(R.string.loading_location));
       theProgressDialog.setIndeterminate(true);
       theProgressDialog.show();
     }
   } else {
     Collections.sort(theAdapter.getBookmarks(), new BookmarkByDistanceComparator(theLocation));
     theAdapter.setTheLocation(theLocation);
   }
 }
  @Override
  public void onPause() {
    super.onPause();
    if (theDB != null) {
      theDB.cleanUp();
      theDB = null;
    }
    if (theProgressDialog != null) {
      theProgressDialog.dismiss();
      theProgressDialog = null;
    }
    theFinder.finish();
    killPendingTasks();
    killRotateTimer();
    killRefreshPredictionTimer();
    getParent().setProgressBarIndeterminateVisibility(false);

    for (final BaseAgency ourAgency : TheApp.theAgencies.values()) {
      ourAgency.finish();
    }
  }