How do I access the camera on Android phones?

前端 未结 4 1696
庸人自扰
庸人自扰 2021-02-13 17:08

I\'ve written a program in Java that takes in an image file and manipulates the image. Now I\'m trying to access the camera so that I can take the photo and give it to the image

4条回答
  •  广开言路
    2021-02-13 17:36

    the most important method is:

    Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
        public void onPictureTaken(byte[] imageData, Camera c) {
    
        }
    };
    

    This method is called when a picture is taken. Here is a good tutorial on this topic: http://www.brighthub.com/mobile/google-android/articles/43414.aspx

    hmm... or maybe you need this one:

    Camera mCamera;
    ...
    public void onClick(View arg0) {
        mCamera.takePicture(null, mPictureCallback, mPictureCallback);
    }
    

    Here is one more example: http://snippets.dzone.com/posts/show/8683

提交回复
热议问题