public ComponentName resolveActivity(@NonNull PackageManager pm) {
if (mComponent != null) {//如果当前组件不为空,则返回组件,为显式Intent
return mComponent;
}
//如果mComponent为空则是隐式Intent,就解析Intent来获得具体是哪个Intent
ResolveInfo info = pm.resolveActivity(
this, PackageManager.MATCH_DEFAULT_ONLY);
if (info != null) {
return new ComponentName(//组装Intent的组件,提供显式调用
info.activityInfo.applicationInfo.packageName,
info.activityInfo.name);
}
return null;
}
Intent.resolveActivity
最新推荐文章于 2024-01-20 00:21:32 发布
本文介绍了如何在Android应用中,当接收隐式Intent时解析并获取具体活动组件名,通过PackageManager进行匹配,最后返回显式ComponentName以便于调用。
6905

被折叠的 条评论
为什么被折叠?



