隱式啓動判斷是否有匹配的Intent

1、PackageManager的resolveActivityspa

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

 

返回可以匹配的Intent,若是不能匹配就返回NULL,code

2、PackageManager的queryIntentActivitiescomponent

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

 

返回全部成功匹配的Activity信息blog

3、Intent的resolveActivityget

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

 

第一個參數表明Intentit

第二個參數:設置PackageManager.MATCH_DEFAULT_ONLYclass

相關文章
相關標籤/搜索