views:

33

answers:

0

Hi friends

I am using android inbuilt camera to take picture and then attaching the same picture to email,

here in the below code i am using Uri imageUri = null; to take picture but in

onActivityResult(int requestCode, int resultCode, Intent data) method i need to retrieve that image how to do it, plz help me.. ,

public class InBuiltCameraTest extends Activity {

private static int TAKE_PICTURE = 1;
private Uri outputFileUri;
private Context context;
private ImageView mImageView;
private File file=null;
private MediaScannerConnection msConn;
Uri imageUri = null;
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.callingactivity);

    context = getApplicationContext();
    mImageView = (ImageView) findViewById(R.id.thumbnail);
    try
    {

        Button opencamera = (Button) findViewById(R.id.opencamera);
        opencamera.setOnClickListener(new OnClickListener()
        {

            public void onClick(View v)
            {

                ContentValues values = new ContentValues();
                values.put(Media.DISPLAY_NAME,"test");
                values.put(Media.TITLE, "My demo image");
                values.put(Media.DESCRIPTION, "Image Captured by Camera via an Intent");
                imageUri = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values);
                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
                startActivityForResult(intent, TAKE_PICTURE);

            }
        });
    } catch (ActivityNotFoundException anfe)
    {
        Log.e("onCreate", "photo intent Activity Not Found", anfe);
    }

}


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
    if (requestCode == TAKE_PICTURE)
    {
        Toast.makeText(context, "picture taken", Toast.LENGTH_LONG).show();


    } else
    {
        Toast.makeText(context, "picture Canceled", Toast.LENGTH_LONG).show();
    }
}

}