public static void ImagePicker(Context context, File tempFile) { Intent intentPick = new Intent(); intentPick.setType("image/*"); intentPick.setAction(Intent.ACTION_GET_CONTENT); Intent intentCamera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intentCamera.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile)); //Tell Camera the location to save the captured photo String pickTitle = context.getString(R.string.UploadPhoto); if (Utils.isIntentInstalled(context, intentPick) && Utils.isIntentInstalled(context, intentCamera)) { Intent chooserIntent = Intent.createChooser(intentPick, pickTitle); chooserIntent.putExtra ( Intent.EXTRA_INITIAL_INTENTS, new Intent[]{intentCamera} ); ((Activity) context).startActivityForResult(chooserIntent, CODE_IMAGE_PICKER); } else if (Utils.isIntentInstalled(context, intentPick)) { Intent chooserIntent = Intent.createChooser(intentPick, pickTitle); ((Activity) context).startActivityForResult(chooserIntent, CODE_IMAGE_PICKER); } else if (Utils.isIntentInstalled(context, intentCamera)) { Intent chooserIntent = Intent.createChooser(intentCamera, pickTitle); ((Activity) context).startActivityForResult(chooserIntent, CODE_IMAGE_PICKER); } else { Utils.DisplayToast(context, "camera and gallery are not installed."); } } public static boolean isIntentInstalled(Context context, Intent intent) { return (intent.resolveActivity(context.getPackageManager()) != null); } public static void DisplayToast(Context context, String msg) { if (toast == null) toast = new Toast(context); toast.cancel(); toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT); toast.show(); }