{"record":{"id":"5590f1bbf8b04647","repo":"beemdevelopment/Aegis","slug":"the-intent-was-null-or-empty","errorCode":null,"errorMessage":"The intent was null or empty!","messagePattern":"The intent was null or empty!","errorType":"exception","errorClass":"ActivityNotFoundException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/info/guardianproject/trustedintents/TrustedIntents.java","lineNumber":257,"sourceCode":"    }\n\n    public boolean areSignaturesEqual(Signature[] sigs0, Signature[] sigs1) {\n        // TODO where is Android's implementation of this that I can just call?\n        if (sigs0 == null || sigs1 == null)\n            return false;\n        if (sigs0.length == 0 || sigs1.length == 0)\n            return false;\n        if (sigs0.length != sigs1.length)\n            return false;\n        for (int i = 0; i < sigs0.length; i++)\n            if (!sigs0[i].equals(sigs1[i]))\n                return false;\n        return true;\n    }\n\n    public void startActivity(Context context, Intent intent) throws CertificateException {\n        if (!isIntentSane(intent))\n            throw new ActivityNotFoundException(\"The intent was null or empty!\");\n        String packageName = intent.getPackage();\n        if (TextUtils.isEmpty(packageName)) {\n            packageName = intent.getComponent().getPackageName();\n            intent.setPackage(packageName);\n        }\n        try {\n            checkTrustedSigner(packageName);\n        } catch (NameNotFoundException e) {\n            e.printStackTrace();\n            throw new ActivityNotFoundException(e.getLocalizedMessage());\n        }\n        context.startActivity(intent);\n    }\n}\n","sourceCodeStart":239,"sourceCodeEnd":272,"githubUrl":"https://github.com/beemdevelopment/Aegis/blob/d6f4e5925a97e4e91593f1542085eae03432a759/app/src/main/java/info/guardianproject/trustedintents/TrustedIntents.java#L239-L272","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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)).","Guard the call site: check intent != null and intent.getAction() != null (or component != null) before invoking startActivity.","If intent may legitimately be absent, skip the call or fall back to plain Context.startActivity instead.","Check isIntentSane() yourself (it is public) to get the precise failure before dispatching."],"exampleFix":"// before\ntrustedIntents.startActivity(context, intent); // intent may be null or bare\n\n// after\nif (intent == null || intent.getAction() == null && intent.getComponent() == null) {\n    intent = new Intent(context, ReceiverActivity.class);\n}\ntrustedIntents.startActivity(context, intent);","handlingStrategy":"validation","validationCode":"if (intent != null && (intent.getAction() != null || intent.getComponent() != null || intent.getData() != null)) {\n    trustedIntents.startActivity(context, intent);\n}","typeGuard":"boolean isIntentUsable(Intent intent) {\n    return intent != null\n        && (intent.getAction() != null || intent.getComponent() != null || intent.getData() != null);\n}","tryCatchPattern":"try {\n    trustedIntents.startActivity(context, intent);\n} catch (ActivityNotFoundException e) {\n    Log.w(TAG, \"Intent not sane or no trusted receiver: \" + e.getMessage());\n    // fall back to default startActivity or notify user\n}","preventionTips":["Always construct the Intent with an explicit action or component before handing it to TrustedIntents.","Validate with the library's own public isIntentSane(intent) before dispatching.","Never pass a possibly-null Intent; initialize it at declaration or fail fast earlier.","Add a unit test asserting every intent your app dispatches via TrustedIntents passes isIntentSane()."],"tags":["android","intent","null-check","validation"],"backgroundTag":"null-argument","analyzedSha":"d6f4e5925a97e4e91593f1542085eae03432a759","analyzedAt":"2026-09-08T00:46:31.111Z","contentChangedAt":"2026-09-08T00:46:31.111Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}