Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

queryIntentActivities shows as deprecated (or returns nothing) on Android 13 and up

ErrorqueryIntentActivities is deprecated

Short 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.

  • Applies to Android Studio Otter, compileSdk 36, Kotlin 2.x, Android 13 to 16
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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/main
  2. 2Match what you see, then jump to its fix

    1. 1The 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. 2The 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

What does the error look like?

  • queryIntentActivities is deprecated
  • queryIntentActivities 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/main

2Fix

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:compileDebugKotlin

Confirmed by developer.android.com

Did this fix it?

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.xml

2Fix

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.apk

Confirmed by developer.android.com

Did this fix it?

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:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.