@SuppressWarnings("deprecation")
  @FixWhenMinSdkVersion(11) // Switch to android.content.ClipboardManager.setPrimaryClip
  @TargetApi(11)
  private boolean onContextItemSelected(MenuItem item, long itemId) {
    Intent intent;
    final AccountIndex index = users[(int) itemId].getIndex(); // final so listener can see value

    // Can't use a switch() statement here because inline constants are turned off.
    if (item.getItemId() == R.id.copy) {
      copyStringToClipboard(this, users[(int) itemId].getPin());
      Toast.makeText(this, R.string.copied_to_clipboard_toast, Toast.LENGTH_SHORT).show();
      return true;
    } else if (item.getItemId() == R.id.check_code) {
      intent = new Intent(Intent.ACTION_VIEW);
      intent.setClass(this, CheckCodeActivity.class);
      intent.putExtra("index", index);
      startActivity(intent);
      return true;
    } else if (item.getItemId() == R.id.rename) {
      final Context context = this; // final so listener can see value
      final View frame =
          getLayoutInflater().inflate(R.layout.rename, (ViewGroup) findViewById(R.id.rename_root));
      final EditText nameEdit = frame.findViewById(R.id.rename_edittext);
      nameEdit.setText(index.getStrippedName()); // User can only edit the stripped name
      new AlertDialog.Builder(this)
          .setTitle(R.string.rename)
          .setView(frame)
          .setPositiveButton(R.string.submit, this.getRenameClickListener(context, index, nameEdit))
          .setNegativeButton(R.string.cancel, null)
          .show();
      return true;
    } else if (item.getItemId() == R.id.delete) {
      AlertDialog.Builder alertDialogBuilder =
          new AlertDialog.Builder(this)
              .setTitle(getString(R.string.remove_account_dialog_title, index))
              .setMessage(
                  Utilities.getStyledTextFromHtml(
                      getString(
                          accountDb.isGoogleAccount(index)
                              ? R.string.remove_google_account_dialog_message
                              : R.string.remove_account_dialog_message)))
              .setPositiveButton(
                  R.string.remove_account_dialog_button_remove,
                  new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int whichButton) {
                      accountDb.delete(index);
                      dismissFirstAccountAddedNoticeDisplay();
                      refreshView(true);
                    }
                  })
              .setNegativeButton(R.string.cancel, null)
              .setIcon(R.drawable.quantum_ic_report_problem_grey600_24);
      alertDialogBuilder.show();
      return true;
    }
    return super.onContextItemSelected(item);
  }
Invoked when a context menu/action bar item is clicked/tapped.

@return {@code true} if the event was consumed, {@code false} otherwise.
java/com/google/android/apps/authenticator/AuthenticatorActivity.java