Intentが使用可能かどうかを検出

530 ワード

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