I am using the camera by creating an intent:
Intent cameraI = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
and then starting it with:
startActivityForResult(cameraI, request);
where request is a predefined constant integer.
I then have the onActivityResult():
public void onActivityResult(int req, int res, Intent data) throws NullPointerException
{
try{
super.onActivityResult(req, res, data);
if(req == request)
{
Bitmap picture = (Bitmap) data.getExtras().get("data");
ImageView image = (ImageView) findViewById(R.id.imageView1);
image.setImageBitmap(picture);
}//if
else
{
Toast.makeText(getApplicationContext(), "No picture taken", 4);
}//else
}catch (NullPointerException e){
String error = "null pointer exception";
Toast.makeText(getApplicationContext(), error, 4);
}
}//onActivityResult
My predicament is that I do not have a camera on this computer. I get eclipse’s default checkerboard and moving square animation. Does this actually function? I have been clicking the “take picture” button but nothing is happening. What I want to happen is to take a single picture, and then return it to the activity that called i. Is that the default action or do I have to specify that I want it to return after taking one picture?
Thanks in advance for any help.
The code in question ended up working. Upon testing on a device, the picture was returned as desired. Eclipse’s emulated camera simply did not work. If i recall correctly you can enable a camera, but that is a different discussion entirely.