我发现getPreferredActivities的工作原理还不太清楚。
例如,如果我要求它返回特定类型的默认应用,getPreferredActivities可以返回多个项吗?
我认为它应该返回它所拥有的过滤器的默认活动,但是文档没有说明它是如何工作的:
Retrieve all preferred activities, previously added with addPreferredActivity(IntentFilter, int, ComponentName[], ComponentName), that are currently registered with the system.
Parameters
outFilters A list in which to place the filters of all of the preferred activities, or null for none.
outActivities A list in which to place the component names of all of the preferred activities, or null for none.
packageName An option package in which you would like to limit the list. If null, all activities will be returned; if non-null, only those activities in the given package are returned.
Returns
Returns the total number of registered preferred activities (the number of distinct IntentFilter records, not the number of unique activity components) that were found.
当然,如果过滤器的规则很少,它可能会返回多个项目,但是如果我要求它返回默认启动器(家庭应用程序)或默认的Web浏览器呢?或默认视频播放器......?
例如,如果我使用this code,它是否会返回仅包含1或0项的列表?