@Override
 public boolean onContextItemSelected(final MenuItem anItem) {
   AdapterView.AdapterContextMenuInfo theInfo = (AdapterContextMenuInfo) anItem.getMenuInfo();
   final int position = theInfo.position;
   final Bookmark theBookmark = theAdapter.getItem(position);
   switch (anItem.getItemId()) {
     case R.id.context_view_stop_on_map:
       Intent myIntent =
           new Intent(getParent(), com.inferiorhumanorgans.WayToGo.MapView.OneStopActivity.class);
       myIntent.putExtra("theStop", (Parcelable) theBookmark.getTheStop());
       this.startActivity(myIntent);
       return true;
     case R.id.context_directions_to:
       Stop.launchWalkingDirectionsTo(this, theBookmark.getTheStop());
       return true;
     case R.id.context_view_bookmark_prediction:
       showPredictionsForItem(position);
       return true;
     case R.id.context_view_bookmark_delete:
       theAdapter.remove(theBookmark);
       theDB.deleteBookmark(theBookmark);
       return true;
     default:
       return super.onContextItemSelected(anItem);
   }
 }
  @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();
  }
  @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();
    }
  }