@Override
  protected void onStop() {
    getContentResolver().unregisterContentObserver(observer);
    cursor.close();

    super.onStop();
  }
  @Override
  protected void onRestart() {
    super.onRestart();

    sendStickyBroadcast(new Intent("com.announcify.ACTION_PLUGIN_CONTACT"));
    refreshList();
  }
  @Override
  protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState, R.layout.main_list);

    getListView().setFastScrollEnabled(true);

    sendStickyBroadcast(new Intent("com.announcify.ACTION_PLUGIN_CONTACT"));

    registerForContextMenu(getListView());

    getListView()
        .setOnItemClickListener(
            new OnItemClickListener() {

              public void onItemClick(
                  final AdapterView<?> arg0, final View arg1, final int arg2, final long arg3) {
                try {
                  startActivity(new Intent(model.getAction(arg3)));
                } catch (final Exception e) {
                  model.remove(arg3);

                  Toast.makeText(
                          AnnouncifyActivity.this,
                          getString(R.string.toast_plugin_not_found),
                          Toast.LENGTH_LONG)
                      .show();
                }
              }
            });

    model = new PluginModel(this);

    refreshList();
    getListView().setSelection(firstVisible);
  }
  @Override
  protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode > 2000) {
      try {
        getPackageManager().getPackageGids(model.getPackage(requestCode - 2000));
      } catch (final NameNotFoundException e) {
        model.remove(requestCode - 2000);
      }
    }
  }
 @Override
 public void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   outState.putInt(KEY_LIST_POSITION, firstVisible);
 }