As other people had explained here, memory will be an issue. To resolve that you can store the images in a hashmap and pass the key around between fragments and activities.
You can use this wrapper class to hold the image for you in-memory.
public class DataWrapper {
private static final DataWrapper instance = new DataWrapper();
private final SparseArray<Object> map = new SparseArray<Object>();
private int currentKeyValue = 1;
public static DataWrapper getInstance() {
return instance;
}
public int putData(final Object data) {
++currentKeyValue;
map.put(currentKeyValue, data);
return currentKeyValue;
}
public Object getData(final int key) {
final Object ret = map.get(key);
map.delete(key);
return ret;
}
}
You can putData into wrapper like this:
final byte[] imageData;
final int imageDataKey = DataWrapper.getInstance().putData(imageData);
data.putExtra(EXTRA_IMAGE, imageDataKey);
You can getData from wrapper like this:
final int imageDataKey = data.getIntExtra(CameraFragment.EXTRA_IMAGE, 0);
final byte[] data = (byte[]) DataWrapper.getInstance().getData(imageDataKey));