intent.resolveActivity() returns null although the other app is installed
intent.resolveActivity(packageManager) returns nullShort answer
From Android 11 (API 30) the system hides most other apps from your app unless your manifest says which ones it needs. So resolveActivity returns null for an app that is installed. Add a queries block to the manifest: list a package name, or an intent signature that matches the apps you want to reach.
Fix it fast
1Find out which cause you have
Check whether your app targets API 30 or higher and whether the manifest has any queries element. No queries element plus a null result points at package visibility.
grep -n "targetSdk" app/build.gradle* grep -n "<queries" app/src/main/AndroidManifest.xml2Match what you see, then jump to its fix
- 1
resolveActivity is null for one specific app (a payment app, a map app, a social app) that is installed on the deviceYou know the target app, but its package is not declaredFix - 2
resolveActivity is null for a SEND, VIEW or similar intent with a MIME type or schemeYou target a kind of app (browser, mail, image sharing), not one packageFix - 3
The failing code resolves or binds to a provider through its authority stringThe query is for a content provider you only know by authorityFix
- 1
What does the error look like?
intent.resolveActivity(packageManager) returns nullstartActivity fails or does nothing for an installed app after targetSdk was raised to 30
Cause 1 of 3
You know the target app, but its package is not declared
1Check
The system filters out other apps by default when your app targets Android 11 or higher. Apps you did not declare are not visible to PackageManager queries.
grep -n -A6 "<queries" app/src/main/AndroidManifest.xml2Fix
Name the packages inside a queries element, as a child of the manifest element.
<manifest ...>
<queries>
<package android:name="com.example.store" />
</queries>
<application ...>
</manifest>3Verify
Rebuild, install, and call resolveActivity again for the same intent. It returns a component name instead of null.
./gradlew installDebugConfirmed by developer.android.com
Cause 2 of 3
You target a kind of app (browser, mail, image sharing), not one package
1Check
When you do not know the package names, an intent signature in queries makes every app with a matching intent filter visible. Each intent element needs exactly one action.
grep -n -B2 -A8 "<intent>" app/src/main/AndroidManifest.xml2Fix
Declare an intent element that matches the intent you build in code.
<queries>
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="image/jpeg" />
</intent>
</queries>3Verify
Install the build and run the intent check again, on a device with a matching app.
./gradlew installDebugConfirmed by developer.android.com
Cause 3 of 3
The query is for a content provider you only know by authority
1Check
Provider authorities are a third way to make an app visible. Look for authority strings in the code that fails.
grep -rn "authorit" app/src/main/java app/src/main/AndroidManifest.xml2Fix
Declare the authority in queries.
<queries>
<provider android:authorities="com.example.settings.files" />
</queries>3Verify
Rebuild and repeat the call that failed.
./gradlew installDebugConfirmed by developer.android.com
How do I stop it coming back?
- Declare the smallest set of packages or intent signatures your app needs. Google treats broad package visibility as a privacy cost.
- Avoid QUERY_ALL_PACKAGES unless your app is of a kind the docs list, such as a browser, antivirus or accessibility app.
- When you write a library that talks to other apps, put the queries element in the library manifest so every host app gets it.
- Treat a null result as a state to handle: show a message or an install link, do not crash.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Mobile apps
adb cannot start because something already holds its port
adb start-server failed
The adb server must bind local TCP port 5037, and every adb client talks to it there.
2 causes, each with a fixMobile apps
The phone shows as unauthorized and Android Studio will not run the app
adb devices lists the phone but Android Studio cannot deploy to it
An unauthorized phone means it has not trusted this computer's RSA key.
3 causes, each with a fixMobile apps
Android Studio cannot pair the phone over Wi-Fi
The Pair devices over Wi-Fi dialog lists no device
Wireless pairing needs the phone on Android 11 or higher and on the same Wi-Fi network as the computer, with current Platform-Tools.
4 causes, each with a fixMobile apps
adb cannot connect to its daemon or start the server
* daemon started successfully *
The adb server is a background process on your computer that listens on TCP port 5037.
2 causes, each with a fixMobile apps
adb prints 'server version doesn't match this client; killing...'
adb server version doesn't match this client; killing...
adb runs a background server, and every adb command is a client.
3 causes, each with a fixMobile apps
adb tcpip 5555 fails because no device is found
adb: more than one device/emulator
adb tcpip only works while the device is attached and listed by adb, because it tells the phone to start listening on port 5555.
4 causes, each with a fix