Android examples for Intent:Open App
Before triggering an implicit intent check if there is any registered activity
//package com.java2s; import java.util.List; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; public class Main { /**/*from w ww. j av a 2 s . c o m*/ * Purpose - Before triggering an implicit intent check if there is any registered activity * * @param context Current Activity context * @param intent Implicit Intent to be called * */ public static boolean isIntentSafe(Context context, Intent intent) { if (context == null) return false; PackageManager packageMgr = context.getPackageManager(); List<ResolveInfo> activities = packageMgr.queryIntentActivities( intent, 0); return (activities.size() > 0); } }