queryIntentActivities shows as deprecated (or returns nothing) on Android 13 and up
queryIntentActivities is deprecatedShort answer
Since API 33, PackageManager has a queryIntentActivities overload that takes PackageManager.ResolveInfoFlags instead of an int. Wrap your flags with ResolveInfoFlags.of(), and call it only on API 33 or higher; keep the old call for older devices. If the list comes back empty on Android 11 or higher, add a queries element to the manifest.
Fix it fast
1Find out which cause you have
Print your minSdk, the target you compile against, and look at which overload the warning points to. The fix depends on whether your app still supports devices below API 33.
grep -n -E "minSdk|targetSdk|compileSdk" app/build.gradle.kts grep -rn "queryIntentActivities" app/src/main2Match what you see, then jump to its fix
- 1
The IDE strikes through queryIntentActivities and the flag you pass is a plain int such as PackageManager.MATCH_DEFAULT_ONLYThe call still uses the int flags overloadFix - 2
The call works in a test project and returns an empty list for apps you know are installedThe new call compiles but returns an empty list on Android 11 or higherFix
- 1
What does the error look like?
queryIntentActivities is deprecatedqueryIntentActivities returns an empty list
Cause 1 of 2
The call still uses the int flags overload
1Check
The reference lists two overloads: one taking an int and one taking PackageManager.ResolveInfoFlags. The ResolveInfoFlags class was added in API level 33, and its of() factory takes a long, so the same MATCH_ constants still work.
grep -rn "queryIntentActivities(" app/src/main2Fix
Choose the overload by Android version. On API 33 and higher use ResolveInfoFlags.of(); below that keep the int overload, with a suppress annotation so the build stays quiet.
import android.content.Intent
import android.content.pm.PackageManager
import android.content.pm.ResolveInfo
import android.os.Build
@Suppress("DEPRECATION")
fun PackageManager.resolveActivities(intent: Intent, flags: Long = 0L): List<ResolveInfo> =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
queryIntentActivities(intent, PackageManager.ResolveInfoFlags.of(flags))
} else {
queryIntentActivities(intent, flags.toInt())
}
// usage
val apps = packageManager.resolveActivities(
Intent(Intent.ACTION_VIEW, Uri.parse("https://example.com")),
PackageManager.MATCH_DEFAULT_ONLY.toLong()
)3Verify
Rebuild: the deprecation warning on that line is gone, and the same code runs on an API 33 or higher device and on an older one.
./gradlew :app:compileDebugKotlinConfirmed by developer.android.com
Cause 2 of 2
The new call compiles but returns an empty list on Android 11 or higher
1Check
When your app targets API 30 or higher, the system filters which other apps queryIntentActivities can see. Open the manifest and look for a queries element.
grep -n -A8 "<queries>" app/src/main/AndroidManifest.xml2Fix
Declare what you need to find. For a set of apps that handle one kind of intent, add an intent signature; for known apps, list their package names. Request QUERY_ALL_PACKAGES only for the few app types the documentation names.
<manifest ...>
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<package android:name="com.example.store" />
</queries>
...
</manifest>3Verify
Reinstall the app and run the query again; the list now contains the matching apps.
adb install -r app/build/outputs/apk/debug/app-debug.apkConfirmed by developer.android.com
How do I stop it coming back?
- Wrap version-dependent PackageManager calls in one helper, so only one place needs the API 33 check.
- Declare queries in the manifest at the time you add any code that looks at other apps.
- Test on one device below API 33 and one above, since the code path differs.
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:
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- Nuclear Home VideoA video-streaming Android app built from scratch, engineered for smooth playback.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
Related fixes
Mobile apps
Android build fails because a product flavor has no flavor dimension
The flavor 'flavor_name' is not assigned to a flavor dimension.
Android Gradle plugin refuses to build when a product flavor is not assigned to a flavor dimension.
2 causes, each with a fixMobile apps
AGP 9 marks the android block as deprecated or fails on BaseExtension
java.lang.ClassCastException: class com.android.build.gradle.internal.dsl.ApplicationExtensionImpl$AgpDecorated_Decorated cannot be cast to class com.android.build.gradle.BaseExtension
AGP 9.0 uses only the new public DSL interfaces.
3 causes, each with a fixMobile apps
Android build fails because two libraries ship the same META-INF file
More than one file was found with OS independent path
Two dependencies put a file at the same path inside the APK and the plugin will not guess which one wins.
3 causes, each with a fixMobile apps
The editor cannot find R, so every R.string and R.id turns red
Unresolved reference: R
R is a class that the build generates from your res folder, in the package named by the module's namespace.
4 causes, each with a fixMobile apps
Android Studio says it could not identify the launch activity when you press Run
Run > Edit Configurations > Launch Options is set to Nothing or to a class that no longer exists
Android Studio launches the activity marked with a MAIN action and a LAUNCHER category in the merged manifest.
3 causes, each with a fixMobile apps
FirebaseInstanceIdService and FirebaseInstanceId.getToken() no longer work
Deprecation warning on FirebaseInstanceId.getInstance().getToken()
Move token handling into a class that extends FirebaseMessagingService and override onNewToken, which runs when a token is first created and whenever it changes.
2 causes, each with a fix