package com.bignerdranch.android.crimeintentrev.utils;

import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;

public class PackageManagerUtils {
	
	private static final String TAG = "PackageManagerUtils";
	
	/**
	 * ¼ì²âÒþÊ½intentÊÇ·ñÓÐActivityÏìÓ¦£¬ÈçÓÐ£¬·µ»Øtrue£¬¾ÍÄÜ°²È«Æô¶¯£¬Èç¹ûÃ»ÓÐ£¬·µ»Øfalse
	 * @param context
	 * @param intent ÒþÊ½intent
	 * @return
	 */
	public static boolean isIntentLaunchSafe(Context context,Intent intent){
		
		PackageManager pm = context.getPackageManager();
		List<ResolveInfo> resolveInfosList = pm.queryIntentActivities(intent, 0);
		int size = resolveInfosList.size();
		LogUtil.d(TAG, "resolveInfo size:"+size);
		
		if(size>0){
			return true;
		}else{
			return false;
		}
	}

}
