public static boolean isIntentAvailable(Context context, String action) {
final PackageManager packageManager = context.getPackageManager();
final Intent intent = new Intent(action);
List<ResolveInfo> list =
packageManager.queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
return list.size() > 0;
}
第二個方法:
透過Intent.resolveActivity(),PackageManager.resolveActivity()這兩個API來作,作法都大同小異。
Reference: [1] [2]
沒有留言:
張貼留言