kernelhcy
9/5/2013 - 3:37 PM

检查一个Intent是否能被处理。

检查一个Intent是否能被处理。

public boolean isIntentExisting(Context context, String action) {  
    final PackageManager packageManager = context.getPackageManager();  
    final Intent intent = new Intent(action);  
    List<ResolveInfo> resolveInfo =  
            packageManager.queryIntentActivities(intent,  
                    PackageManager.MATCH_DEFAULT_ONLY);  
   if (resolveInfo.size() > 0) {  
        return true;  
    }  
   return false; 
}