I have an intent chooser that allows me to pick image from gallery or camera like this:
Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT,null)
You can distinguish by using REQUEST_CODE
private static final int PICK_FROM_CAMERA = 1;
private static final int PICK_FROM_GALLARY = 2;
/* For Image capture from camera */
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, PICK_FROM_CAMERA);
/* For Image capture from Gallary*/
startActivityForResult(new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI),
PICK_FROM_GALLARY);
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
switch (requestCode) {
case PICK_FROM_CAMERA:
if (resultCode == Activity.RESULT_OK) {
Bitmap bitmapImage = (Bitmap) intent.getExtras().get("data");
}
break;
case PICK_FROM_GALLARY:
if (resultCode == Activity.RESULT_OK) {
Uri mImageCaptureUri = intent.getData();
}
break;
}
}