Java tutorial
//package com.java2s; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.net.Uri; import android.os.Parcelable; import android.provider.MediaStore; import android.support.annotation.NonNull; import java.util.ArrayList; import java.util.List; public class Main { public static Intent createTakePictureIntent(@NonNull Context context, @NonNull Uri outputFileUri) { List<Intent> cameraIntents = createTakePictureIntentList(context, outputFileUri); if (cameraIntents.isEmpty()) return null; Intent chooserIntent = new Intent(cameraIntents.get(0)); cameraIntents.remove(0); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[cameraIntents.size()])); return chooserIntent; } public static List<Intent> createTakePictureIntentList(@NonNull Context context, @NonNull Uri outputFileUri) { List<Intent> cameraIntents = new ArrayList<>(); Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); PackageManager packageManager = context.getPackageManager(); List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0); for (ResolveInfo res : listCam) { String packageName = res.activityInfo.packageName; Intent intent = new Intent(captureIntent); intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); intent.setPackage(packageName); intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); cameraIntents.add(intent); } return cameraIntents; } }