public
Intent getImageIntent() {
final
List<Intent> cameraIntents =
new
ArrayList<Intent>();
final
Intent captureIntent =
new
Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
final
PackageManager packageManager = context.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);
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;
}
After that the onActivityResult executes:
private
void
handleSmallCameraPhoto(Intent intent) {
Bundle extras = intent.getExtras();
mProductBitmap = (Bitmap) extras.get(
"data"
);
imgProduct.setImageBitmap(mProductBitmap);
}