I’m still fresh to Android programming and I don;t quite get how does Camera activity returns data.
I’m learning from video tutorials and I’m having problems understanding something, so there it goes (exceptions from code):
int cameraData = 0;
intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, cameraData);
I understand that this parts starts Activity with implicit intent and wait for Camera to return results
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
bmp = (Bitmap) extras.get("data");
iv.setImageBitmap(bmp);
}
}
And this one waits for receives data from that Activity, where
requestCodeis 0 fromcameraDataresultCodeisRESULT_OKif picture was takendatais data receiver from camera
I’m having difficulty with understanding bmp = (Bitmap) extras.get("data");
How exactly should I know which String key to use to get particular data? I can’t find information on what kind of data and in what form Camera returns results.
The documentation says that the “data” key holds a thumbnail and that if you need full image you should provide a filename by calling
putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f))on your Intent, where f is a File.