beemdevelopment/Aegis · error · ActivityNotFoundException

The intent was null or empty!

Error message

The intent was null or empty!

What it means

TrustedIntents.startActivity() throws ActivityNotFoundException with this message when isIntentSane(intent) fails, i.e. the Intent is null or has no action/data/component (empty). The library refuses to dispatch an intent it cannot validate against pinned receiver certificates, since sanity checking is a prerequisite for resolving the trusted target app.

Solutions

  1. Ensure the Intent passed to startActivity() is non-null and has an action and/or component set before calling (e.g. new Intent(context, TargetActivity.class) or new Intent(ACTION).setPackage(pkg)).
  2. Guard the call site: check intent != null and intent.getAction() != null (or component != null) before invoking startActivity.
  3. If intent may legitimately be absent, skip the call or fall back to plain Context.startActivity instead.
  4. Check isIntentSane() yourself (it is public) to get the precise failure before dispatching.

Example fix

// before
trustedIntents.startActivity(context, intent); // intent may be null or bare

// after
if (intent == null || intent.getAction() == null && intent.getComponent() == null) {
    intent = new Intent(context, ReceiverActivity.class);
}
trustedIntents.startActivity(context, intent);
Defensive patterns

Strategy: validation

Validate before calling

if (intent != null && (intent.getAction() != null || intent.getComponent() != null || intent.getData() != null)) {
    trustedIntents.startActivity(context, intent);
}

Type guard

boolean isIntentUsable(Intent intent) {
    return intent != null
        && (intent.getAction() != null || intent.getComponent() != null || intent.getData() != null);
}

Try / catch

try {
    trustedIntents.startActivity(context, intent);
} catch (ActivityNotFoundException e) {
    Log.w(TAG, "Intent not sane or no trusted receiver: " + e.getMessage());
    // fall back to default startActivity or notify user
}

Prevention

When it happens

Trigger: Calling startActivity(context, null); or calling it with a bare new Intent("") / new Intent() that has no action, data URI, or component set, so isIntentSane() returns false.

Common situations: Constructing the Intent conditionally and passing null when an early branch was skipped; building an Intent with only extras or only a package name but no action/component; refactoring code that previously used Context.startActivity directly, which tolerates vaguer intents, onto TrustedIntents which does not.

Related errors


AI-assisted analysis of beemdevelopment/Aegis@d6f4e5925a (2026-09-08). Data as JSON: /api/errors/5590f1bbf8b04647. Report an issue: GitHub.

Appendix: source

Thrown at app/src/main/java/info/guardianproject/trustedintents/TrustedIntents.java:257

    }

    public boolean areSignaturesEqual(Signature[] sigs0, Signature[] sigs1) {
        // TODO where is Android's implementation of this that I can just call?
        if (sigs0 == null || sigs1 == null)
            return false;
        if (sigs0.length == 0 || sigs1.length == 0)
            return false;
        if (sigs0.length != sigs1.length)
            return false;
        for (int i = 0; i < sigs0.length; i++)
            if (!sigs0[i].equals(sigs1[i]))
                return false;
        return true;
    }

    public void startActivity(Context context, Intent intent) throws CertificateException {
        if (!isIntentSane(intent))
            throw new ActivityNotFoundException("The intent was null or empty!");
        String packageName = intent.getPackage();
        if (TextUtils.isEmpty(packageName)) {
            packageName = intent.getComponent().getPackageName();
            intent.setPackage(packageName);
        }
        try {
            checkTrustedSigner(packageName);
        } catch (NameNotFoundException e) {
            e.printStackTrace();
            throw new ActivityNotFoundException(e.getLocalizedMessage());
        }
        context.startActivity(intent);
    }
}

View on GitHub (pinned to d6f4e5925a)