Fork me on GitHub

隐式启动判断是否有匹配的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

 

posted @ 2016-08-28 23:47  森林森  阅读(2759)  评论(0编辑  收藏  举报