首页 > 代码库 > 隐式启动判断是否有匹配的Intent

隐式启动判断是否有匹配的Intent

一、PackageManager的resolveActivity

  public abstract ResolveInfo resolveActivity(Intent intent, int flags);
getPackageManager().resolveActivity();

 

返回能够匹配的Intent,如果不能匹配就返回NULL,

二、PackageManager的queryIntentActivities

public abstract List<ResolveInfo> queryIntentActivities(Intent intent,        int flags);
getPackageManager().queryIntentActivities(intent,PackageManager.MATCH_DEFAULT_ONLY);

 

返回所有成功匹配的Activity信息

三、Intent的resolveActivity

 public ComponentName resolveActivity(PackageManager pm)
Intent intent = new Intent();        ComponentName componentName = intent.resolveActivity();

 

第一个参数代表Intent

第二个参数:设置PackageManager.MATCH_DEFAULT_ONLY

 

隐式启动判断是否有匹配的Intent