I have a class, ExpandableListAdapter
that fires an intent that opens the camera
ImageView itemImage = (ImageView) convertView.findViewById(R.id.itemImage);
itemImage.setImageBitmap(childItem.Image);
itemImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Camera camera = new Camera(context);
// The method below fires the intent to the camera app
camera.dispatchTakePictureIntent(childItem);
}
});
The childItem
is an object from this class:
public class Item {
public String Name;
public Bitmap Image;
public boolean IsChecked;
}
The camera takes a picture and stores it on the memory card.
I have overridden void onActivityResult(int requestCode, int resultCode, Intent data)
in the activity that uses the adapter.
How do I get the item object (that I sent in the intent) back in the activity method:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {}
EDIT: This is where the intent is fired:
public void dispatchTakePictureIntent(Item item) {
// ... I make a temp file with the name item.Name and fire the intent
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
((Activity) context).startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);