I am starting implicit intent for crop with string "com.android.camera.action.CROP" on android 11. when application is first installed can not resolve its activity by this code.
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setType("image/*");
//to check whether there is an cropping app present or not
List<ResolveInfo> resInfoList = getPackageManager().queryIntentActivities(
intent, MATCH_DEFAULT_ONLY);
it is not resolving for the first time and runs for second time it gets the activities that can handle the intent.
I assume you target Android 11 (API 30), which requires you to specify all intents to external apps in a
queriesnode inside your AndroidManifest.xml like follows:Read more here and here. Also there's a medium post on the matter here.
NOTE: The intent
com.android.camera.action.CROPis based on the camera app from AOSP which might be missing on some devices, please refer to Commonsware's old blogpost about it: https://commonsware.com/blog/2013/01/23/no-android-does-not-have-crop-intent.html