I am using an intent chooser to let users decide what app to use in order to pick an image from camera or gallery. Problem is that my code bellow also show file explorer applications like ES File Manager or the stock file manager.
Screenshot for demonstration : http://image.noelshack.com/fichiers/2015/22/1432565769-xmeedd.png
Also, i dont know which part of my code list those two file explorers.
So is there a way to only keep "Camera" which is the stock camera app, and "Galerie", which is the stock Gallery app ?
Sorry for bad english !
private void openImageIntent() {
// Determine Uri of camera image to save.
final File root = new File(Environment.getExternalStorageDirectory() + File.separator + "TempDirectory" + File.separator);
root.mkdirs();
final String fname = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date())+".jpg";
final File sdImageMainDirectory = new File(root, fname);
outputFileUri = Uri.fromFile(sdImageMainDirectory);
// Camera.
// Is it this part that list the two unwanted file explorers ?
final List<Intent> cameraIntents = new ArrayList<Intent>();
final Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
final PackageManager packageManager = getPackageManager();
final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0);
for(ResolveInfo res : listCam) {
final String packageName = res.activityInfo.packageName;
final 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);
}
// Filesystem.
// Is it this part that list the two unwanted file explorers ?
final Intent galleryIntent = new Intent();
galleryIntent.setType("image/*");
galleryIntent.setAction(Intent.ACTION_GET_CONTENT);
galleryIntent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
// Chooser of filesystem options.
final Intent chooserIntent = Intent.createChooser(galleryIntent, "Select Source");
// Add the camera options.
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[cameraIntents.size()]));
startActivityForResult(chooserIntent, CAMERA_PIC_REQUEST);
}