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 isIntentAvailable(final Context context, final String action) { final PackageManager packageManager = context.getPackageManager(); final Intent intent = new Intent(action); final List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; }
From source file:Main.java
/** * Indicates whether the specified action can be used as an intent example: isIntentAvailable(this, * "com.google.zxing.client.android.SCAN"); * * @param pContext/*from w ww . ja va 2 s . c om*/ * @param pAction * @return */ private static boolean isIntentAvailable(Context pContext, String pAction) { final PackageManager packageManager = pContext.getPackageManager(); final Intent intent = new Intent(pAction); List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; }
From source file:Main.java
/** * @return the List of applications which support Mushroom protocol. *///w w w. ja va2 s . c o m public static List<ResolveInfo> getMushroomApplicationList(PackageManager packageManager) { Intent intent = new Intent(); intent.setAction(ACTION); intent.addCategory(CATEGORY); return packageManager.queryIntentActivities(intent, 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 . j av a 2s . c o m * * @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(final Context context, final 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:Main.java
public static void shareOnTwitter(Context pContext, String urlToShare) { Intent tweetIntent = new Intent(Intent.ACTION_SEND); tweetIntent.putExtra(Intent.EXTRA_TEXT, urlToShare); tweetIntent.setType("text/plain"); PackageManager packManager = pContext.getPackageManager(); List<ResolveInfo> resolvedInfoList = packManager.queryIntentActivities(tweetIntent, PackageManager.MATCH_DEFAULT_ONLY); boolean resolved = false; for (ResolveInfo resolveInfo : resolvedInfoList) { if (resolveInfo.activityInfo.packageName.startsWith("com.twitter.android")) { tweetIntent.setClassName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name); resolved = true;// ww w .j a v a 2 s. c o m break; } } if (resolved) { pContext.startActivity(tweetIntent); } else { Intent i = new Intent(); i.putExtra(Intent.EXTRA_TEXT, urlToShare); i.setAction(Intent.ACTION_VIEW); i.setData(Uri.parse("https://twitter.com/intent/tweet?text=message&via=profileName")); pContext.startActivity(i); } }
From source file:Main.java
public static boolean hasCamera(Activity activity) { PackageManager packageManager = activity.getPackageManager(); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; }
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> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; }
From source file:Main.java
public static boolean isIntentAvailable(Context context, final Intent intent) { final PackageManager packageManager = context.getPackageManager(); // final Intent intent = new Intent(action); List<ResolveInfo> resolveInfo = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (resolveInfo.size() > 0) { return true; }//ww w.ja va 2s.c om return false; }
From source file:Main.java
public static boolean isIntentAvailable(final Context context, final String className) { final PackageManager packageManager = context.getPackageManager(); final Intent intent = new Intent(className); final List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return (list.size() > 0); }
From source file:Main.java
public static Intent getImageFromGalleryCamera(Context context) { // Determine Uri of camera image to save. File root = new File( Environment.getExternalStorageDirectory() + File.separator + "dianta/camera" + File.separator); root.mkdirs();//from w w w. ja va 2 s . c om String fname = "dianta-" + System.currentTimeMillis() + ".jpg"; File sdImageMainDirectory = new File(root, fname); Uri outputFileUri = Uri.fromFile(sdImageMainDirectory); // camera List<Intent> cameraIntents = new ArrayList<>(); Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); PackageManager lPackageManager = context.getPackageManager(); List<ResolveInfo> listCam = lPackageManager.queryIntentActivities(captureIntent, 0); for (ResolveInfo rInfo : listCam) { String packageName = rInfo.activityInfo.packageName; Intent lIntent = new Intent(captureIntent); lIntent.setComponent(new ComponentName(rInfo.activityInfo.packageName, rInfo.activityInfo.name)); lIntent.setPackage(packageName); //save camera result to external storage lIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); cameraIntents.add(lIntent); } //ugly hacks for camera helper lastCameraImageSaved = outputFileUri; // gallery Intent galleryIntent = new Intent(); galleryIntent.setType("image/*"); galleryIntent.setAction(Intent.ACTION_PICK); Intent chooserIntent = Intent.createChooser(galleryIntent, "Pilih Sumber"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[cameraIntents.size()])); return chooserIntent; }