You asked to see the code executed after startActivity
and here it is.
In your app:
Activity.startActivity(Intent)
calls
Activity.startActivity(Intent, Bundle)
, which calls
Activity.startActivityForResult(Intent, int)
, which calls
FragmentActivity.startActivityForResult(Intent, int)
, which calls
Activity.startActivityForResult(Intent, int)
, which calls
Activity.startActivityForResult(Intent, int, Bundle)
, which calls
Instrumentation.execStartActivity(Context, IBinder, IBinder, Activity, Intent, int, Bundle)
, which calls
IActivityManager.startActivity(IApplicationThread, String, Intent, String, IBinder, String, int, int, ProfilerInfo, Bundle)
The call on the last line is a remote process call, meaning that in your app process a the method is called on a proxy IActivityManager
instance which forwards it to another process, in this case a system process.
Up to this point, no Intent filtering has taken place.
In Android's system process IActivityManager
resolved to ActivityManagerService
and:
ActivityManagerService.startivity(IApplicationThread, String, Intent, String, IBinder, String, int, int, ProfilerInfo, Bundle)
calls
ActivityManagerService.startActivityAsUser(IApplicationThread, String, Intent, String, IBinder, String, int, int, ProfilerInfo, Bundle, int)
, which calls
ActivityStackSupervisor.startActivityMayWait(IApplicationThread, int, String, Intent, String, IVoiceInteractionSession, IVoiceInteractor, IBinder, String, int, int, ProfilerInfo, WaitResult, Configuration, Bundle, boolean, int, IActivityContainer, TaskRecord)
, which calls
ActivityStackSupervisor.resolveActivity(Intent, String, int, ProfilerInfo, int)
, which calls
IPackageManager.resolveIntent(Intent, String, int, int)
This is the where MATCH_DEFAULT_ONLY is added, as nkalra0123 said.
Also, this is another remote method invocation. IPackageManager
gets resolved to PackageManagerService
, and from there it goes like this:
PackageManagerService.resolveIntent(Intent, String, int, int)
calls
PackageManagerService.queryIntentActivities(Intent, String, int, int)
, which attempts to get all the Activities for the Intent package. This gets the Activities from your package and then calls
PackageService.ActivityIntentResolver.queryIntentForPackage(Intent, String, int, ArrayList<PackageParser.Activity>, int)
, which gets the IntentFilters in your package and then calls
PackageService.ActivityIntentResolver.queryIntentFromList(Intent, String, boolean , ArrayList<F[]>, int)
, which calls
IntentResolver.buildResolveList(...)
, which runs all the IntentFilters it found against the data in your Intent, taking into account whether or not we need CATEGORY_DEFAULT
, and adding the matching IntentFilters to a list accordingly.
All these call method calls then return and eventually some object somewhere will figure out there were no matching IntentFilters. I omit that here because this is the relevant part of the answer.