List of usage examples for android.content.pm PackageManager queryIntentActivities
public abstract List<ResolveInfo> queryIntentActivities(Intent intent, @ResolveInfoFlags int flags);
From source file:Main.java
/** * Gets the activity list.//from w w w . j a va 2 s . c o m * * @param context * the context * @param intent * the intent * * @return the activity list */ public static List<Hashtable<String, Object>> getActivityList(Context context, Intent intent) { List<Hashtable<String, Object>> result = new ArrayList<Hashtable<String, Object>>(); PackageManager pm = context.getPackageManager(); List<ResolveInfo> list = pm.queryIntentActivities(intent.addCategory("android.intent.category.DEFAULT"), 0); for (ResolveInfo info : list) { Hashtable<String, Object> h = new Hashtable<String, Object>(); CharSequence labelSeq = info.activityInfo.loadLabel(pm); String label = labelSeq != null ? labelSeq.toString() : info.activityInfo.name; h.put(LABEL, label); h.put(INTENT, activityIntent(info.activityInfo.applicationInfo.packageName, info.activityInfo.name)); result.add(h); } Collections.sort(result, displayNameComparator); return result; }
From source file:Main.java
public static boolean isIntentAvailable(Context context, String action) { final PackageManager packageManager = context.getPackageManager(); final Intent intent = new Intent(action); List<ResolveInfo> resolveInfo = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return resolveInfo != null && !resolveInfo.isEmpty(); }
From source file:com.codyy.lib.utils.ActivityUtils.java
/** * ?launcher activity//from www .j av a2 s. c o m * * @param context * @param packageName ?? * @return launcher activity */ public static String getLauncherActivity(Context context, String packageName) { Intent intent = new Intent(Intent.ACTION_MAIN, null); intent.addCategory(Intent.CATEGORY_LAUNCHER); PackageManager pm = context.getPackageManager(); List<ResolveInfo> infos = pm.queryIntentActivities(intent, 0); for (ResolveInfo info : infos) { if (info.activityInfo.packageName.equals(packageName)) { return info.activityInfo.name; } } return "no " + packageName; }
From source file:Main.java
public static Boolean isActionAvailable(Activity activity, int action) { Log.d(TAG, "[AirImagePickerUtils] Entering isActionAvailable"); if (action == CROP_ACTION) { return isCropAvailable(activity); }/* w w w .ja v a2 s .c om*/ final PackageManager packageManager = activity.getPackageManager(); List<ResolveInfo> list = packageManager.queryIntentActivities(getIntentForAction(action), PackageManager.MATCH_DEFAULT_ONLY); Log.d(TAG, "[AirImagePickerUtils] Exiting isActionAvailable"); return list.size() > 0; }
From source file:Main.java
/** * Indicates whether the specified action can be used as an intent. This * method queries the package manager for installed packages that can * respond to an intent with the specified action. If no suitable package is * found, this method returns false.//from w w w.jav a 2 s . c om * * @param context * The application's environment. * @param action * The Intent action to check for availability. * * @return True if an Intent with the specified action can be sent and * responded to, false otherwise. */ 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; }
From source file:com.todoroo.astrid.voice.VoiceRecognizer.java
/** * Call this to see if your phone supports voiceinput in its current configuration. * If this method returns false, it could also mean that Google Voicesearch is simply * not installed.//from ww w . ja v a2s . c o m * If this method returns true, internal use of it enables the registered microphone-button. * * @return whether this phone supports voiceinput */ public static boolean voiceInputAvailable(Context context) { PackageManager pm = context.getPackageManager(); List<ResolveInfo> activities = pm .queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0); return (activities.size() != 0); }
From source file:Main.java
/** * Used to check whether there is a specialized handler for a given intent. * @param intent The intent to check with. * @return Whether there is a specialized handler for the given intent. *///from w w w . j ava2 s. co m private static boolean hasSpecializedHandlerIntents(Context context, Intent intent) { try { PackageManager pm = context.getPackageManager(); List<ResolveInfo> handlers = pm.queryIntentActivities(intent, PackageManager.GET_RESOLVED_FILTER); if (handlers == null || handlers.size() == 0) { return false; } for (ResolveInfo resolveInfo : handlers) { IntentFilter filter = resolveInfo.filter; if (filter == null) continue; if (filter.countDataAuthorities() == 0 || filter.countDataPaths() == 0) continue; if (resolveInfo.activityInfo == null) continue; return true; } } catch (RuntimeException e) { Log.e(TAG, "Runtime exception while getting specialized handlers"); } return false; }
From source file:Main.java
/** * Check if action available installed// www . j a va2s .c o m * * @param context Context of current app * @param action Package of application to check * @return true if passed package installed */ public static boolean isIntentAvailable(Context context, String action) { final PackageManager packageManager = context.getPackageManager(); final Intent intent = new Intent(action); assert packageManager != null; List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; }
From source file:com.app.common.util.IntentUtils.java
public static void startEmailActivity(Context context, String to, String subject, String body) { final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("message/rfc822"); if (!TextUtils.isEmpty(to)) { intent.putExtra(Intent.EXTRA_EMAIL, new String[] { to }); }//from w w w . j a v a 2 s . com if (!TextUtils.isEmpty(subject)) { intent.putExtra(Intent.EXTRA_SUBJECT, subject); } if (!TextUtils.isEmpty(body)) { intent.putExtra(Intent.EXTRA_TEXT, body); } final PackageManager pm = (PackageManager) context.getPackageManager(); try { if (pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).size() == 0) { intent.setType("text/plain"); } } catch (Exception e) { Log.w("Exception encountered while looking for email intent receiver.", e); } context.startActivity(intent); }
From source file:Main.java
public static List<ResolveInfo> getBrowsers(Context context) { PackageManager pm = context.getPackageManager(); Intent query = new Intent(); query.setAction(Intent.ACTION_VIEW); query.setData(Uri.parse("http://localhost")); return pm.queryIntentActivities(query, 0); }