Android Intent Check isIntentSafe(Context context, Intent intent)

Here you can find the source of isIntentSafe(Context context, Intent intent)

Description

Purpose - Before trigerring an implicit intent check if there is any registered activity

Parameter

Parameter Description
context Current Activity context
intent Implicit Intent to be called

Declaration

public static boolean isIntentSafe(Context context, Intent intent) 

Method Source Code

//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 w w . j  a  v  a 2 s . c  o m
     * Purpose - Before trigerring 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);
    }
}

Related

  1. getAction(Intent intent)
  2. isActionEquals(Intent intent, String expected)
  3. isActionEquals(Intent intent, String expected)
  4. isBroadcastSafe(Context context, Intent intent)
  5. isIntentAvailable(Context context, String action)
  6. genPendingBroadcast(Context context, int requestCode, Intent broadcastIntent)
  7. isIntentAvailable(@Nonnull Context context, @Nonnull String action)
  8. isIntentAvailable(Context context, String action)
  9. isDownloadsDocument(Uri uri)