androidandroid-package-managers

android why the ResolveInfo got from resolveActivity() is different than from queryIntentActivities()


When looking at the ResolveInfo return from resolveActivity() and queryIntentActivities(),

why the ResolveInfo is different from these two calls for the same intent?

the viewIntent is Intent(Intent.ACTION_VIEW, Uri.parse(deeplinkData), and the one returned from resolveActivity has unrelated packagename/name:

ResolveInfo info = pm.resolveActivity(viewIntent, PackageManager.MATCH_DEFAULT_ONLY);

        System.out.println("+++ 111 resolveActivity(), info.activityInfo.packageName:  "+info.activityInfo.packageName+",\ninfo.activityInfo.name: "+info.activityInfo.name);

it has log:

+++ 111 resolveActivity(), info.activityInfo.packageName: android, 

info.activityInfo.name: com.android.internal.app.ResolverActivity

where using queryIntentActivities

List<ResolveInfo> resInfo = pm.queryIntentActivities(viewIntent, 0);
if (!resInfo.isEmpty()){
            for (ResolveInfo info : resInfo) {

                System.out.println("+++ queryIntentActivities(), info.activityInfo.packageName: "+ (info.activityInfo.packageName));
                System.out.println("+++ +++ queryIntentActivities(), info.activityInfo.name: "+ (info.activityInfo.name));

                ......
            }
        }

has log:

+++ queryIntentActivities(), info.activityInfo.packageName: com.client.android.debug
+++ +++ queryIntentActivities(), info.activityInfo.name: com.client.android.NewsActivity
+++ queryIntentActivities(), info.activityInfo.packageName: com.android.chrome
+++ +++ queryIntentActivities(), info.activityInfo.name: com.google.android.apps.chrome.IntentDispatcher

Solution

  • resolveActivity() returns the component that would be started if you call startActivity(). That will be:

    In your case, you are getting the chooser activity (com.android.internal.app.ResolverActivity).