Last active
December 9, 2016 11:22
-
-
Save dGorod/e58dcbcce5ad0829fa0142333ac7505c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.content.Intent; | |
import android.content.pm.PackageManager; | |
import android.content.pm.ResolveInfo; | |
import android.net.Uri; | |
import android.support.annotation.NonNull; | |
import java.util.List; | |
/** | |
* Created by Dmitriy Gorodnytskiy on 03-Feb-16. | |
*/ | |
public abstract class IntentsUtil { | |
private IntentsUtil() { } | |
public static boolean isActionAvailable(@NonNull Context context, @NonNull String action) { | |
Intent intent = new Intent(Intent.ACTION_VIEW).setData(Uri.parse(action)); | |
return isActionAvailable(context, intent); | |
} | |
public static boolean isActionAvailable(@NonNull Context context, @NonNull Intent intent) { | |
PackageManager manager = context.getPackageManager(); | |
List<ResolveInfo> infos = manager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); | |
return !infos.isEmpty(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment