How to solve queryIntentActivities deprecated in API 33
12:21 09 Sep 2022

I am getting a strange behavior in Android Studio with API33. In the following code,

Intent chooser = Intent.createChooser(sharingIntent, filename);
List resInfoList = context.getPackageManager().queryIntentActivities(chooser, android.content.pm.PackageManager.MATCH_DEFAULT_ONLY);

I am getting queryIntentActivities(Intent,int) in PackageManager has been deprecated.

In the docs, it says: This method was deprecated in API level 33. Use queryIntentActivities(android.content.Intent, android.content.pm.PackageManager.ResolveInfoFlags) instead.

I tried changing Intent with android.content.Intent, but get the same problem. PackageManager.MATCH_DEFAULT_ONLY is one of the possible flag values, so I do not understand what this error is trying to tell me...

android android-studio deprecated