public static Intent createTakePictureIntent(Activity ctx,Uri savingUri){
  if (savingUri == null) {
    throw new NullPointerException("Uri cannot be null");
  }
  final List<Intent> cameraIntents=new ArrayList<Intent>();
  final Intent captureIntent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
  final PackageManager packageManager=ctx.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,savingUri);
    cameraIntents.add(intent);
  }
  final Intent galleryIntent=new Intent();
  galleryIntent.setType("image/*");
  galleryIntent.setAction(Intent.ACTION_GET_CONTENT);
  final Intent chooserIntent=Intent.createChooser(galleryIntent,"Select Source");
  chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,cameraIntents.toArray(new Parcelable[]{}));
  return chooserIntent;
}

public static Intent createTakePictureIntent ( Activity ctx , Uri savingUri ) { if ( savingUri == null ) { throw new NullPointerException ( "Uri cannot be null" ) ; } final List < Intent > cameraIntents = new ArrayList < Intent > ( ) ; final Intent captureIntent = new Intent ( MediaStore . ACTION_IMAGE_CAPTURE ) ; final PackageManager packageManager = ctx . 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 , savingUri ) ; cameraIntents . add ( intent ) ; } final Intent galleryIntent = new Intent ( ) ; galleryIntent . setType ( "image/*" ) ; galleryIntent . setAction ( Intent . ACTION_GET_CONTENT ) ; final Intent chooserIntent = Intent . createChooser ( galleryIntent , "Select Source" ) ; chooserIntent . putExtra ( Intent . EXTRA_INITIAL_INTENTS , cameraIntents . toArray ( new Parcelable [ ] { } ) ) ; return chooserIntent ; }
creates a action_image_capture photo & action_get_content intent . this intent will be aggregation of intents required to take picture from gallery and camera at the minimum . the intent will also be directed towards the apps that are capable of sourcing the image data . for e . g . dropbox , astro file manager .
