Search This Blog

Sunday 24 August 2014

Develop camera part 3

How to take a picture:

For taking a picture you can use this Camera.takePicture()  method.this method start after once preview start.you can use this method Camera.PictureCallback and Camera.ShutterCallback objects pass in to Camera.takePicture().

If you want to grab images continously, you can create a Camera.PreviewCallback that implements onPreviewFrame(). For something in between, you can capture only selected preview frames, or set up a delayed action to call takePicture().

How to restart preview:

After once start and take the picture . you must restart preview before take the picture in this example . here restart is done by overloading the shutter button 

@Override
public void onClick(View v) {
    switch(mPreviewState) {
    case K_STATE_FROZEN:
        mCamera.startPreview();
        mPreviewState = K_STATE_PREVIEW;
        break;

    default:
        mCamera.takePicture( null, rawCallback, null);
        mPreviewState = K_STATE_BUSY;
    } // switch
    shutterBtnConfig();
}

Stop the preview and release the camera :

After the using the camera you need to stop and release that camera it's called the clean up time.this is the last step of the using camera .here stop means release the camera object. now here if you don't know what is camera object and how it will be create then use this link click here :http://androidbasedapplication.blogspot.in/2014/07/develop-camera-using-eclips.html 

Now you have a question about when you should release the camera ? then i will tell you that having your preview surface destroyed is a pretty good hint that it's time to stop preview and release the camera  tis method from the preview class.

public void surfaceDestroyed(SurfaceHolder holder) {
    // Surface will be destroyed when we return, so stop the preview.
    if (mCamera != null) {
        // Call stopPreview() to stop updating the preview surface.
        mCamera.stopPreview();
    }
}
/**
 * When this function returns, mCamera will be null.
 */
private void stopPreviewAndFreeCamera() {

    if (mCamera != null) {
        // Call stopPreview() to stop updating the preview surface.
        mCamera.stopPreview();
    
        // Important: Call release() to release the camera for use by other
        // applications. Applications should release the camera immediately
        // during onPause() and re-open() it during onResume()).
        mCamera.release();
    
        mCamera = null;
    }
}
Earlier in the lesson, this procedure was also part of the setCamera() method, so initializing a camera always begins with stopping the preview.

if you wants to print the contain then follow here 

Print contain :

After the using the camera if you wants to print that contain and you wants to send your friend then refer this domain print contain. 

in android 4.4 and higher frame work provide the printing images and document directly from the your android application here you can print the 3 types contain given below:
1)print the image 

2)print the HTML document

3)print the custom document 
Being able to print information from your android application gives users a way to see a larger version of the content from the application or share it with another person who is not using your application . Printing also allows then to create a shanp shot  of the content  that does not depend on having a device, sufficient battery power or a wireless network connection

1 comment:

  1. ey Nice Blog!! Thanks For Sharing!!!Wonderful blog & good post.Its really helpful for me, waiting for a more new post. Keep Blogging!
    mobile application development course in coimbatore
    IT security training in coimbatore

    ReplyDelete