@Override
    public void finish() {
        if (accountAuthenticatorResponse != null) {
            // send the result bundle back if set, otherwise send an error.
            if (resultBundle != null) {
                accountAuthenticatorResponse.onResult(resultBundle);
            } else {
                accountAuthenticatorResponse.onError(AccountManager.ERROR_CODE_CANCELED,
                    "canceled");
            }
            accountAuthenticatorResponse = null;
        }
        super.finish();
    }
Sends the result or a Constants.ERROR_CODE_CANCELED error if a result isn't present.
app/src/main/java/com/github/pockethub/android/ui/base/AccountAuthenticatorAppCompatActivity.java