开发者

Android Defer to Camera

Is there a way, from within my own application, to open up the default camera app and use that to get a picture/video? I keep trying to look it up but I only ever find instructions on cloning the camera app myself (usually with very bad instructions). I know this can be done with the iPhone, I would be surprised 开发者_开发技巧if it wasn't possible with Android.


To get the camera to take a picture and then get the image that it just took use the following

// Call to take the picture using the default camera
startActivityForResult(new Intent("android.media.action.IMAGE_CAPTURE"), PICK_FROM_CAMERA);

// After the camera intent finished returns the uri of the image taken
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
    if (requestCode == PICK_FROM_CAMERA)
    {
        Uri uri = data.getData();
                // set the imageview image via uri 
                _previewImage.setImageURI(uri);
    }
}


Here's some sample code where he starts the Camera intent and gets the image taken:

http://www.androidph.com/2008/11/camera-capture.html

(Warning, it's about a year old, so it will need a little updating).


Yep, you can. That's one of the ideas behind Android's intents.

Take a look here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜