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
public static boolean isPlayStoreInstalled(Context context) { if (null == context) return false; try {/*w w w. ja va2 s . c o m*/ Intent market = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=dummy")); PackageManager manager = context.getPackageManager(); List<ResolveInfo> list = manager.queryIntentActivities(market, 0); return list.size() > 0; } catch (Exception e) { return false; } }
From source file:Main.java
/** * @deprecated/* w ww. j av a 2 s . c om*/ * use isGooglePlayInstalled(Context ctx) instead * @param ctx * @return */ public static boolean isAndroidMarketInstalled(Context ctx) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://search?q=foo")); PackageManager pm = ctx.getPackageManager(); List<ResolveInfo> list = pm.queryIntentActivities(intent, 0); if (list.size() > 0) { return true; } else { return false; } }
From source file:Main.java
public static boolean isIntentAvailable(Context ctx, Intent in) { PackageManager packageManager = ctx.getPackageManager(); List<ResolveInfo> activities = packageManager.queryIntentActivities(in, 0); return (activities == null) ? false : (activities.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 the specified intent. If no suitable package is * found, this method returns false./* www .j a v a 2s. c o m*/ * * @param context The application's environment. * @param intent The Intent 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(final Context context, final Intent intent) { final PackageManager packageManager = context.getPackageManager(); List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; }
From source file:Main.java
/** * Returns true if the intent action is available on the device, false * otherwise.//from w w w . j a v a 2 s . c o m */ public static boolean isIntentAvailable(Context ctx, String action) { PackageManager pm = ctx.getPackageManager(); Intent intent = new Intent(action); return pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).size() > 0; }
From source file:Main.java
/** * Method to get weather the intent is available in system to perform * specified operation/* w ww . ja va 2s . c o m*/ * * @param ctx * @param in * @return */ private static boolean isIntentAvailable(Context ctx, Intent in) { PackageManager packageManager = ctx.getPackageManager(); List<ResolveInfo> activities = packageManager.queryIntentActivities(in, 0); return (activities == null) ? false : (activities.size() > 0); }
From source file:Main.java
public static void shareToGMail(Context context, String[] email, String subject, String content) { Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); emailIntent.putExtra(Intent.EXTRA_EMAIL, email); emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); emailIntent.setType("text/plain"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, content); final PackageManager pm = context.getPackageManager(); final List<ResolveInfo> matches = pm.queryIntentActivities(emailIntent, 0); ResolveInfo best = null;/*from ww w . j a v a 2 s .c om*/ for (final ResolveInfo info : matches) if (info.activityInfo.packageName.endsWith(".gm") || info.activityInfo.name.toLowerCase().contains("gmail")) best = info; if (best != null) emailIntent.setClassName(best.activityInfo.packageName, best.activityInfo.name); context.startActivity(emailIntent); }
From source file:Main.java
public static ArrayList<String> getHaveIntent(Intent intent, PackageManager pm) { ArrayList<String> ret = new ArrayList<String>(); Iterator<ResolveInfo> obj = pm.queryIntentActivities(intent, 0).iterator(); if (obj != null) { while (obj.hasNext()) { ResolveInfo resolveinfo = (ResolveInfo) obj.next(); if (resolveinfo.activityInfo.packageName != null) { String packName = resolveinfo.activityInfo.packageName; ret.add(packName);// w ww . ja va 2 s . co m } } } return ret; }
From source file:Main.java
/** Checks if the device can send SMS messages. * * @param context Context for obtaining the package manager. * @return true if you can send SMS, false otherwise. *//* www. j a v a 2s. com*/ public static boolean canSendSms(Context context) { Uri smsUri = Uri.parse("smsto:12345"); Intent smsIntent = new Intent(Intent.ACTION_SENDTO, smsUri); PackageManager smspackageManager = context.getPackageManager(); List<ResolveInfo> smsresolveInfos = smspackageManager.queryIntentActivities(smsIntent, 0); return smsresolveInfos.size() > 0; }
From source file:Main.java
public static String e(Context context) { if (c == null) { StringBuilder stringbuilder = new StringBuilder(); PackageManager packagemanager = context.getPackageManager(); List list = packagemanager.queryIntentActivities( new Intent("android.intent.action.VIEW", Uri.parse("geo:0,0?q=donuts")), 0x10000); if (list == null || list.size() == 0) stringbuilder.append("m"); List list1 = packagemanager.queryIntentActivities( new Intent("android.intent.action.VIEW", Uri.parse("market://search?q=pname:com.google")), 0x10000);/*from w ww .jav a 2 s. c om*/ if (list1 == null || list1.size() == 0) { if (stringbuilder.length() > 0) stringbuilder.append(","); stringbuilder.append("a"); } List list2 = packagemanager.queryIntentActivities( new Intent("android.intent.action.VIEW", Uri.parse("tel://6509313940")), 0x10000); if (list2 == null || list2.size() == 0) { if (stringbuilder.length() > 0) stringbuilder.append(","); stringbuilder.append("t"); } c = stringbuilder.toString(); } return c; }